Skip to content

Commit 2ce161e

Browse files
authored
feat: 1、新增水印文案自定义功能;2、input-item输入框组件新增清除功能(可用于快捷清除水印文案);3、偏好设置、主题切换、语言选择、是否全屏按钮新增动画效果 (vbenjs#6800)
* feature: 新增水印文案自定义功能; * chore: 偏好设置、主题切换、语言选择、是否全屏按钮新增动画效果
1 parent 33306a5 commit 2ce161e

16 files changed

Lines changed: 92 additions & 19 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ function handleMakeAll() {
106106
notifications.value.forEach((item) => (item.isRead = true));
107107
}
108108
watch(
109-
() => preferences.app.watermark,
110-
async (enable) => {
109+
() => ({
110+
enable: preferences.app.watermark,
111+
content: preferences.app.watermarkContent,
112+
}),
113+
async ({ enable, content }) => {
111114
if (enable) {
112115
await updateWatermark({
113-
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
116+
content:
117+
content ||
118+
`${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
114119
});
115120
} else {
116121
destroyWatermark();

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ function handleMakeAll() {
106106
notifications.value.forEach((item) => (item.isRead = true));
107107
}
108108
watch(
109-
() => preferences.app.watermark,
110-
async (enable) => {
109+
() => ({
110+
enable: preferences.app.watermark,
111+
content: preferences.app.watermarkContent,
112+
}),
113+
async ({ enable, content }) => {
111114
if (enable) {
112115
await updateWatermark({
113-
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
116+
content:
117+
content ||
118+
`${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
114119
});
115120
} else {
116121
destroyWatermark();

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,16 @@ function handleMakeAll() {
107107
}
108108
109109
watch(
110-
() => preferences.app.watermark,
111-
async (enable) => {
110+
() => ({
111+
enable: preferences.app.watermark,
112+
content: preferences.app.watermarkContent,
113+
}),
114+
async ({ enable, content }) => {
112115
if (enable) {
113116
await updateWatermark({
114-
content: `${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
117+
content:
118+
content ||
119+
`${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
115120
});
116121
} else {
117122
destroyWatermark();

packages/@core/base/design/src/css/ui.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,17 @@
8585
.z-popup {
8686
z-index: var(--popup-z-index);
8787
}
88+
89+
@keyframes shrink {
90+
0% {
91+
transform: scale(1);
92+
}
93+
94+
50% {
95+
transform: scale(0.9);
96+
}
97+
98+
100% {
99+
transform: scale(1);
100+
}
101+
}

packages/@core/preferences/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const defaultPreferences: Preferences = {
2929
name: 'Vben Admin',
3030
preferencesButtonPosition: 'auto',
3131
watermark: false,
32+
watermarkContent: '',
3233
zIndex: 200,
3334
},
3435
breadcrumb: {

packages/@core/preferences/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ interface AppPreferences {
7575
* @zh_CN 是否开启水印
7676
*/
7777
watermark: boolean;
78+
/**
79+
* @zh_CN 水印文案
80+
*/
81+
watermarkContent: string;
7882
/** z-index */
7983
zIndex: number;
8084
}

packages/@core/ui-kit/shadcn-ui/src/components/full-screen/full-screen.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ isFullscreen.value = !!(
2121
);
2222
</script>
2323
<template>
24-
<VbenIconButton @click="toggle">
24+
<VbenIconButton
25+
class="hover:animate-[shrink_0.3s_ease-in-out]"
26+
@click="toggle"
27+
>
2528
<Minimize v-if="isFullscreen" class="text-foreground size-4" />
2629
<Maximize v-else class="text-foreground size-4" />
2730
</VbenIconButton>

packages/effects/layouts/src/widgets/language-toggle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function handleUpdate(value: string | undefined) {
3131
:model-value="preferences.app.locale"
3232
@update:model-value="handleUpdate"
3333
>
34-
<VbenIconButton>
34+
<VbenIconButton class="hover:animate-[shrink_0.3s_ease-in-out]">
3535
<Languages class="text-foreground size-4" />
3636
</VbenIconButton>
3737
</VbenDropdownRadioMenu>

packages/effects/layouts/src/widgets/preferences/blocks/general/general.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { SUPPORT_LANGUAGES } from '@vben/constants';
33
import { $t } from '@vben/locales';
44
5+
import InputItem from '../input-item.vue';
56
import SelectItem from '../select-item.vue';
67
import SwitchItem from '../switch-item.vue';
78
@@ -12,6 +13,7 @@ defineOptions({
1213
const appLocale = defineModel<string>('appLocale');
1314
const appDynamicTitle = defineModel<boolean>('appDynamicTitle');
1415
const appWatermark = defineModel<boolean>('appWatermark');
16+
const appWatermarkContent = defineModel<string>('appWatermarkContent');
1517
const appEnableCheckUpdates = defineModel<boolean>('appEnableCheckUpdates');
1618
</script>
1719

@@ -22,9 +24,23 @@ const appEnableCheckUpdates = defineModel<boolean>('appEnableCheckUpdates');
2224
<SwitchItem v-model="appDynamicTitle">
2325
{{ $t('preferences.dynamicTitle') }}
2426
</SwitchItem>
25-
<SwitchItem v-model="appWatermark">
27+
<SwitchItem
28+
v-model="appWatermark"
29+
@update:model-value="
30+
(val) => {
31+
if (!val) appWatermarkContent = '';
32+
}
33+
"
34+
>
2635
{{ $t('preferences.watermark') }}
2736
</SwitchItem>
37+
<InputItem
38+
v-if="appWatermark"
39+
v-model="appWatermarkContent"
40+
:placeholder="$t('preferences.watermarkContent')"
41+
>
42+
{{ $t('preferences.watermarkContent') }}
43+
</InputItem>
2844
<SwitchItem v-model="appEnableCheckUpdates">
2945
{{ $t('preferences.checkUpdates') }}
3046
</SwitchItem>

packages/effects/layouts/src/widgets/preferences/blocks/input-item.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SelectOption } from '@vben/types';
33
44
import { useSlots } from 'vue';
55
6-
import { CircleHelp } from '@vben/icons';
6+
import { CircleHelp, CircleX } from '@vben/icons';
77
88
import { Input, VbenTooltip } from '@vben-core/shadcn-ui';
99
@@ -47,6 +47,17 @@ const slots = useSlots();
4747
<slot name="tip"></slot>
4848
</VbenTooltip>
4949
</span>
50-
<Input v-model="inputValue" class="h-8 w-[165px]" />
50+
<div class="relative">
51+
<Input
52+
v-model="inputValue"
53+
class="h-8 w-[165px]"
54+
:placeholder="placeholder"
55+
/>
56+
<CircleX
57+
v-if="inputValue"
58+
class="hover:text-foreground text-foreground/60 absolute right-2 top-1/2 size-3 -translate-y-1/2 transform cursor-pointer"
59+
@click="() => (inputValue = '')"
60+
/>
61+
</div>
5162
</div>
5263
</template>

0 commit comments

Comments
 (0)