mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-11 10:00:08 +08:00
93 lines
2.2 KiB
Vue
93 lines
2.2 KiB
Vue
<script lang="ts" setup>
|
|
import api from '@/api'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
// 多语言支持
|
|
const { t } = useI18n()
|
|
|
|
// 定义输入
|
|
const props = defineProps({
|
|
conf: {
|
|
type: Object as PropType<{ [key: string]: any }>,
|
|
required: true,
|
|
},
|
|
})
|
|
|
|
if (!props.conf.filepath) {
|
|
props.conf.filepath = '/moviepilot/.config/rclone/rclone.conf'
|
|
}
|
|
|
|
if (!props.conf.content) {
|
|
props.conf.content = t('dialog.rcloneConfig.defaultContent')
|
|
}
|
|
|
|
// 定义事件
|
|
const emit = defineEmits(['done', 'close'])
|
|
|
|
// 完成
|
|
async function handleDone() {
|
|
await savaRcloneConfig()
|
|
emit('done')
|
|
}
|
|
|
|
// 保存rclone设置
|
|
async function savaRcloneConfig() {
|
|
try {
|
|
await api.post(`storage/save/rclone`, props.conf)
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
}
|
|
|
|
// 重置配置
|
|
async function handleReset() {
|
|
try {
|
|
const result: { [key: string]: any } = await api.get('/storage/reset/rclone')
|
|
if (result.success) {
|
|
// 重置成功
|
|
alertType.value = 'success'
|
|
handleDone()
|
|
} else {
|
|
alertType.value = 'error'
|
|
text.value = result.message
|
|
}
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<VDialog width="50rem" scrollable max-height="85vh">
|
|
<VCard :title="t('dialog.rcloneConfig.title')" class="rounded-t">
|
|
<VDialogCloseBtn @click="emit('close')" />
|
|
<VCardText>
|
|
<VRow>
|
|
<VCol cols="12">
|
|
<VTextField v-model="props.conf.filepath" :label="t('dialog.rcloneConfig.filePath')" />
|
|
</VCol>
|
|
<VCol cols="12">
|
|
<VAceEditor
|
|
v-model:value="props.conf.content"
|
|
lang="ini"
|
|
theme="monokai"
|
|
style="block-size: 30rem"
|
|
class="rounded"
|
|
>
|
|
</VAceEditor>
|
|
</VCol>
|
|
</VRow>
|
|
</VCardText>
|
|
<VCardActions>
|
|
<VSpacer />
|
|
<VBtn variant="elevated" @click="handleReset" prepend-icon="mdi-restore" class="px-5 me-3">
|
|
{{ t('dialog.rcloneConfig.reset') }}
|
|
</VBtn>
|
|
<VBtn variant="elevated" @click="handleDone" prepend-icon="mdi-check" class="px-5 me-3">
|
|
{{ t('dialog.rcloneConfig.complete') }}
|
|
</VBtn>
|
|
</VCardActions>
|
|
</VCard>
|
|
</VDialog>
|
|
</template>
|