From f893f306fab14d452faf5995d5744f9437d6b6b3 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 22 Dec 2025 15:09:19 +0800 Subject: [PATCH] feat: Retain historical settings when toggling watermark --- frontend/src/global/use-logo.ts | 1 + frontend/src/layout/index.vue | 2 +- frontend/src/store/interface/index.ts | 1 + frontend/src/store/modules/global.ts | 1 + frontend/src/utils/xpack.ts | 2 ++ frontend/src/views/setting/panel/index.vue | 15 ++++++++------- .../src/views/setting/panel/watermark/index.vue | 1 + 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/frontend/src/global/use-logo.ts b/frontend/src/global/use-logo.ts index 1b86eecdb..5cf1a83fe 100644 --- a/frontend/src/global/use-logo.ts +++ b/frontend/src/global/use-logo.ts @@ -14,6 +14,7 @@ export const useLogo = async () => { globalStore.themeConfig.loginBackground = res.data?.loginBackground; globalStore.themeConfig.loginBtnLinkColor = res.data?.loginBtnLinkColor; globalStore.themeConfig.favicon = res.data.favicon; + globalStore.watermarkShow = res.data.watermarkShow === 'Enable'; try { globalStore.watermark = JSON.parse(res.data.watermark); } catch { diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index 807dbcdec..87b968e9e 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -24,7 +24,7 @@ - + {{ $t('commons.button.enable') }} @@ -87,7 +87,7 @@ {{ $t('commons.button.disable') }} -
+
{{ $t('commons.button.view') }} @@ -274,7 +274,7 @@ const form = reactive({ panelName: '', theme: '', watermark: '', - watermarkItem: '', + watermarkShow: '', themeColor: {} as ThemeColor, menuTabs: '', language: '', @@ -372,12 +372,12 @@ const search = async () => { globalStore.themeConfig.theme = form.theme; form.proxyDocker = xpackRes.data.proxyDocker; form.watermark = xpackRes.data.watermark; + form.watermarkShow = xpackRes.data.watermarkShow; try { globalStore.watermark = JSON.parse(xpackRes.data.watermark); } catch { globalStore.watermark = null; } - form.watermarkItem = xpackRes.data.watermark ? 'Enable' : 'Disable'; } } else { globalStore.themeConfig.theme = form.theme; @@ -421,7 +421,7 @@ const onChangeThemeColor = () => { }; const onChangeWatermark = async () => { - if (form.watermarkItem === 'Enable') { + if (form.watermarkShow === 'Enable') { watermarkRef.value.acceptParams(form.watermark); return; } @@ -431,10 +431,11 @@ const onChangeWatermark = async () => { }) .then(async () => { loading.value = true; - await updateXpackSettingByKey('Watermark', '') + await updateXpackSettingByKey('WatermarkShow', 'Disable') .then(() => { loading.value = false; globalStore.watermark = null; + globalStore.watermarkShow = false; search(); MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); }) @@ -443,7 +444,7 @@ const onChangeWatermark = async () => { }); }) .catch(() => { - form.watermarkItem = 'Enable'; + form.watermarkShow = 'Enable'; }); }; diff --git a/frontend/src/views/setting/panel/watermark/index.vue b/frontend/src/views/setting/panel/watermark/index.vue index 151c0144b..e574cefcc 100644 --- a/frontend/src/views/setting/panel/watermark/index.vue +++ b/frontend/src/views/setting/panel/watermark/index.vue @@ -127,6 +127,7 @@ const onSave = async (formEl: FormInstance | undefined) => { rotate: form.rotate, gap: form.gap, }; + globalStore.watermarkShow = true; handleClose(); return; })