From aba2ee29dd2da85bbb05004cccf5f52428d1a11b Mon Sep 17 00:00:00 2001 From: Aqr-K <95741669+Aqr-K@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:53:02 +0800 Subject: [PATCH] feat(settings): AccountSettingSearch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加 整合多名称资源搜索结果、下载站点字幕、交互式搜索自动下载用户 --- src/views/setting/AccountSettingSearch.vue | 121 ++++++++++++++++++++- 1 file changed, 117 insertions(+), 4 deletions(-) diff --git a/src/views/setting/AccountSettingSearch.vue b/src/views/setting/AccountSettingSearch.vue index fcd4a192..5fd0f713 100644 --- a/src/views/setting/AccountSettingSearch.vue +++ b/src/views/setting/AccountSettingSearch.vue @@ -16,6 +16,18 @@ const allSites = ref([]) // 选中订阅站点 const selectedSites = ref([]) +// 系统设置 +const SystemSettings = ref({ + Basis: { + + }, + Advanced: { + SEARCH_MULTIPLE_NAME: false, + DOWNLOAD_SUBTITLE: false, + AUTO_DOWNLOAD_USER: '', + }, +}) + // 媒体信息数据源字典 const mediaSourcesDict = [ { @@ -95,7 +107,7 @@ const saveSelectedSites = debounce(async () => { } }, debounceTime) -// 调用API查询下载器设置 +// 调用API查询设置 async function loadSearchSetting() { try { const result1: { [key: string]: any } = await api.get('system/setting/SEARCH_SOURCE') @@ -121,20 +133,76 @@ const saveSearchSetting = debounce(async () => { ) if (result1.success && result2.success) { - $toast.success('保存媒体数据源设置成功') + $toast.success('保存设置成功') + await reloadSystem() } else { - $toast.error('保存媒体数据源设置失败!') + $toast.error('保存设置失败!') } } catch (error) { console.log(error) } }, debounceTime) +// 加载系统设置 +async function loadSystemSettings() { + try { + const result: { [key: string]: any } = await api.get('system/env') + if (result.success) { + // 将API返回的值赋值给SystemSettings + for (const sectionKey of Object.keys(SystemSettings.value) as Array) { + Object.keys(SystemSettings.value[sectionKey]).forEach((key: string) => { + let v: any + if (result.data.hasOwnProperty(key)) { + v = result.data[key] + // 空字符串转为null,避免空字符串导致前端显示问题 + if (v === '') { + v = null + } + (SystemSettings.value[sectionKey] as any)[key] = v + } + }) + } + } else $toast.error('加载设置失败!') + } catch (error) { + console.log(error) + } +} + +// 保存设置 +const saveSystemSettings = debounce(async (value: any) => { + try { + const result: { [key: string]: any } = await api.post('system/env', value) + if (result.success) { + $toast.success('保存设置成功') + await reloadSystem() + await loadSystemSettings() + } else { + $toast.error('保存设置失败!') + } + } catch (error) { + console.log(error) + } +}, debounceTime) + +// 重载系统生效配置 +async function reloadSystem() { + try { + const result: { [key: string]: any } = await api.get('system/reload') + if (result.success) { + $toast.success('系统配置已生效') + await loadSystemSettings() + } else $toast.error('重载系统失败!') + } catch (error) { + console.log(error) + } +} + onMounted(() => { querySites() queryFilterRuleGroups() querySelectedSites() loadSearchSetting() + loadSystemSettings() }) @@ -155,7 +223,7 @@ onMounted(() => { clearable chips :items="mediaSourcesDict" - label="媒体数据源" + label="媒体搜索数据源" hint="搜索媒体信息时使用的数据源以及排序" persistent-hint /> @@ -215,4 +283,49 @@ onMounted(() => { + + + + + 高级设置 + 设置交互搜索自动下载用户ID、字幕。 + + + + + + + + + + + + + + + + +
+ 保存 +
+
+
+
+
+