Skip to content

Commit a0feeb1

Browse files
authored
fix: watermark settings in the preferences modified accidentally (vbenjs#5823)
1 parent df6341f commit a0feeb1

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

apps/web-antd/src/layouts/basic.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ watch(
110110
async (enable) => {
111111
if (enable) {
112112
await updateWatermark({
113-
content: `${userStore.userInfo?.username}`,
113+
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
114114
});
115115
} else {
116116
destroyWatermark();

apps/web-ele/src/layouts/basic.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ watch(
110110
async (enable) => {
111111
if (enable) {
112112
await updateWatermark({
113-
content: `${userStore.userInfo?.username}`,
113+
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
114114
});
115115
} else {
116116
destroyWatermark();

apps/web-naive/src/layouts/basic.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ watch(
111111
async (enable) => {
112112
if (enable) {
113113
await updateWatermark({
114-
content: `${userStore.userInfo?.username}`,
114+
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
115115
});
116116
} else {
117117
destroyWatermark();

packages/effects/hooks/src/use-watermark.ts

-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import type { Watermark, WatermarkOptions } from 'watermark-js-plus';
22

33
import { nextTick, onUnmounted, readonly, ref } from 'vue';
44

5-
import { updatePreferences } from '@vben/preferences';
6-
75
const watermark = ref<Watermark>();
86
const unmountedHooked = ref<boolean>(false);
97
const cachedOptions = ref<Partial<WatermarkOptions>>({
@@ -48,7 +46,6 @@ export function useWatermark() {
4846
...options,
4947
};
5048
watermark.value = new Watermark(cachedOptions.value);
51-
updatePreferences({ app: { watermark: true } });
5249
await watermark.value?.create();
5350
}
5451

@@ -69,7 +66,6 @@ export function useWatermark() {
6966
watermark.value.destroy();
7067
watermark.value = undefined;
7168
}
72-
updatePreferences({ app: { watermark: false } });
7369
}
7470

7571
// 只在第一次调用时注册卸载钩子,防止重复注册以致于在路由切换时销毁了水印

playground/src/layouts/basic.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" setup>
22
import type { NotificationItem } from '@vben/layouts';
33
4-
import { computed, ref, watch } from 'vue';
4+
import { computed, onBeforeMount, ref, watch } from 'vue';
55
66
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
77
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
@@ -126,7 +126,7 @@ watch(
126126
async (enable) => {
127127
if (enable) {
128128
await updateWatermark({
129-
content: `${userStore.userInfo?.username}`,
129+
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
130130
});
131131
} else {
132132
destroyWatermark();
@@ -136,6 +136,12 @@ watch(
136136
immediate: true,
137137
},
138138
);
139+
140+
onBeforeMount(() => {
141+
if (preferences.app.watermark) {
142+
destroyWatermark();
143+
}
144+
});
139145
</script>
140146

141147
<template>

0 commit comments

Comments
 (0)