From 27582004daab1aeed1fee21167ffa2fd569c7f2c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 11 Sep 2025 08:31:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=85=8D=E7=BD=AE=E5=90=91?= =?UTF-8?q?=E5=AF=BC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useSetupWizard.ts | 3 + src/views/setup/DownloaderSettingsStep.vue | 9 --- src/views/setup/MediaServerSettingsStep.vue | 82 ++++++++++++++++++-- src/views/setup/NotificationSettingsStep.vue | 14 +++- 4 files changed, 90 insertions(+), 18 deletions(-) diff --git a/src/composables/useSetupWizard.ts b/src/composables/useSetupWizard.ts index 8460544a..9c7a937f 100644 --- a/src/composables/useSetupWizard.ts +++ b/src/composables/useSetupWizard.ts @@ -32,6 +32,7 @@ export interface WizardData { name: string config: any sync_libraries: any[] + switchs: any[] } notification: { type: string @@ -110,6 +111,7 @@ const wizardData = ref({ name: '', config: {}, sync_libraries: [], + switchs: [], }, notification: { type: '', @@ -410,6 +412,7 @@ export function useSetupWizard() { // 根据通知类型验证必输项 const config = wizardData.value.notification.config || {} + alert(wizardData.value.notification.type) switch (wizardData.value.notification.type) { case 'wechat': if (!config.WECHAT_CORPID?.trim()) { diff --git a/src/views/setup/DownloaderSettingsStep.vue b/src/views/setup/DownloaderSettingsStep.vue index 54733b2c..77730e8d 100644 --- a/src/views/setup/DownloaderSettingsStep.vue +++ b/src/views/setup/DownloaderSettingsStep.vue @@ -117,15 +117,6 @@ const { wizardData, selectDownloader, validationErrors } = useSetupWizard() required /> - - - import { useI18n } from 'vue-i18n' import { useSetupWizard } from '@/composables/useSetupWizard' +import api from '@/api' const { t } = useI18n() const { wizardData, selectMediaServer, validationErrors } = useSetupWizard() + +// 同步媒体库选项 +const librariesOptions = ref<{ title: string; value: string | undefined }[]>([ + { + title: t('common.all'), + value: 'all', + }, +]) + +// 调用API查询媒体库 +async function loadLibrary(server: string) { + try { + console.log('Loading library for server:', server) + const result: any[] = await api.get('mediaserver/library', { params: { server } }) + if (result && result.length > 0) { + librariesOptions.value = result.map(item => ({ + title: item.name, + value: item.id?.toString(), + })) + console.log('Loaded libraries:', librariesOptions.value) + } else { + librariesOptions.value = [] + console.log('No libraries found') + } + librariesOptions.value.unshift({ + title: t('common.all'), + value: 'all', + }) + } catch (e) { + console.log('Error loading library:', e) + } +} + +// 选择媒体服务器并自动加载媒体库 +async function selectMediaServerWithLibrary(type: string) { + selectMediaServer(type) + // 如果选择了媒体服务器类型,自动加载媒体库 + if (type && wizardData.value.mediaServer.name) { + await loadLibrary(wizardData.value.mediaServer.name) + } +} + +// 组件挂载时检查是否需要加载媒体库 +onMounted(async () => { + // 如果已经有媒体服务器配置,自动加载媒体库 + if (wizardData.value.mediaServer.type && wizardData.value.mediaServer.name) { + await loadLibrary(wizardData.value.mediaServer.name) + } +}) + +// 监听媒体服务器配置变化,自动加载媒体库 +watch( + () => [wizardData.value.mediaServer.type, wizardData.value.mediaServer.name], + async ([type, name]) => { + console.log('Media server changed:', { type, name }) + if (type && name) { + await loadLibrary(name) + } + }, + { immediate: true }, +)