Skip to content

Commit 63d5d70

Browse files
authored
feat: Retain historical settings when toggling watermark (#11429)
Refs #11392
1 parent 0be7360 commit 63d5d70

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

frontend/src/global/use-logo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useLogo = async () => {
1414
globalStore.themeConfig.loginBackground = res.data?.loginBackground;
1515
globalStore.themeConfig.loginBtnLinkColor = res.data?.loginBtnLinkColor;
1616
globalStore.themeConfig.favicon = res.data.favicon;
17+
globalStore.watermarkShow = res.data.watermarkShow === 'Enable';
1718
try {
1819
globalStore.watermark = JSON.parse(res.data.watermark);
1920
} catch {

frontend/src/layout/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525

2626
<el-watermark
27-
v-if="globalStore.isMasterProductPro && globalStore.watermark"
27+
v-if="globalStore.isMasterProductPro && globalStore.watermarkShow && globalStore.watermark"
2828
:content="loadContent()"
2929
:font="{
3030
fontSize: globalStore.watermark.fontSize,

frontend/src/store/interface/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface GlobalState {
3636
isFullScreen: boolean;
3737
openMenuTabs: boolean;
3838
watermark: Watermark;
39+
watermarkShow: boolean;
3940
isOnRestart: boolean;
4041
agreeLicense: boolean;
4142
hasNewVersion: boolean;

frontend/src/store/modules/global.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const GlobalStore = defineStore({
2828
loginBtnLinkColor: '',
2929
},
3030
watermark: null,
31+
watermarkShow: false,
3132
openMenuTabs: false,
3233
isFullScreen: false,
3334
isOnRestart: false,

frontend/src/utils/xpack.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function resetXSetting() {
1111
globalStore.themeConfig.logoWithText = '';
1212
globalStore.themeConfig.favicon = '';
1313
globalStore.watermark = null;
14+
globalStore.watermarkShow = false;
1415
globalStore.masterAlias = '';
1516
}
1617

@@ -116,6 +117,7 @@ export async function getXpackSettingForTheme() {
116117
if (res2.data?.theme) {
117118
globalStore.themeConfig.theme = res2.data.theme;
118119
}
120+
globalStore.watermarkShow = res2.data.watermarkShow === 'Enable';
119121
try {
120122
globalStore.watermark = JSON.parse(res2.data.watermark);
121123
} catch {

frontend/src/views/setting/panel/index.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@
7979
</el-form-item>
8080

8181
<el-form-item :label="$t('setting.watermark')" v-if="isMasterProductPro" prop="watermark">
82-
<el-radio-group class="w-full" @change="onChangeWatermark" v-model="form.watermarkItem">
82+
<el-radio-group class="w-full" @change="onChangeWatermark" v-model="form.watermarkShow">
8383
<el-radio-button value="Enable">
8484
<span>{{ $t('commons.button.enable') }}</span>
8585
</el-radio-button>
8686
<el-radio-button value="Disable">
8787
<span>{{ $t('commons.button.disable') }}</span>
8888
</el-radio-button>
8989
</el-radio-group>
90-
<div v-if="form.watermarkItem === 'Enable'">
90+
<div v-if="form.watermarkShow === 'Enable'">
9191
<div>
9292
<el-button link type="primary" @click="onChangeWatermark">
9393
{{ $t('commons.button.view') }}
@@ -274,7 +274,7 @@ const form = reactive({
274274
panelName: '',
275275
theme: '',
276276
watermark: '',
277-
watermarkItem: '',
277+
watermarkShow: '',
278278
themeColor: {} as ThemeColor,
279279
menuTabs: '',
280280
language: '',
@@ -372,12 +372,12 @@ const search = async () => {
372372
globalStore.themeConfig.theme = form.theme;
373373
form.proxyDocker = xpackRes.data.proxyDocker;
374374
form.watermark = xpackRes.data.watermark;
375+
form.watermarkShow = xpackRes.data.watermarkShow;
375376
try {
376377
globalStore.watermark = JSON.parse(xpackRes.data.watermark);
377378
} catch {
378379
globalStore.watermark = null;
379380
}
380-
form.watermarkItem = xpackRes.data.watermark ? 'Enable' : 'Disable';
381381
}
382382
} else {
383383
globalStore.themeConfig.theme = form.theme;
@@ -421,7 +421,7 @@ const onChangeThemeColor = () => {
421421
};
422422
423423
const onChangeWatermark = async () => {
424-
if (form.watermarkItem === 'Enable') {
424+
if (form.watermarkShow === 'Enable') {
425425
watermarkRef.value.acceptParams(form.watermark);
426426
return;
427427
}
@@ -431,10 +431,11 @@ const onChangeWatermark = async () => {
431431
})
432432
.then(async () => {
433433
loading.value = true;
434-
await updateXpackSettingByKey('Watermark', '')
434+
await updateXpackSettingByKey('WatermarkShow', 'Disable')
435435
.then(() => {
436436
loading.value = false;
437437
globalStore.watermark = null;
438+
globalStore.watermarkShow = false;
438439
search();
439440
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
440441
})
@@ -443,7 +444,7 @@ const onChangeWatermark = async () => {
443444
});
444445
})
445446
.catch(() => {
446-
form.watermarkItem = 'Enable';
447+
form.watermarkShow = 'Enable';
447448
});
448449
};
449450

frontend/src/views/setting/panel/watermark/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const onSave = async (formEl: FormInstance | undefined) => {
127127
rotate: form.rotate,
128128
gap: form.gap,
129129
};
130+
globalStore.watermarkShow = true;
130131
handleClose();
131132
return;
132133
})

0 commit comments

Comments
 (0)