Skip to content

Commit 6bb66a0

Browse files
committed
feat(projects): add full screen watermark
1 parent 719f02f commit 6bb66a0

File tree

7 files changed

+52
-0
lines changed

7 files changed

+52
-0
lines changed

src/App.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { computed } from 'vue';
33
import { ConfigProvider } from 'ant-design-vue';
4+
import type { WatermarkProps } from 'ant-design-vue';
45
import { useAppStore } from './store/modules/app';
56
import { useThemeStore } from './store/modules/theme';
67
import { antdLocales } from './locales/antd';
@@ -15,12 +16,33 @@ const themeStore = useThemeStore();
1516
const antdLocale = computed(() => {
1617
return antdLocales[appStore.locale];
1718
});
19+
20+
const watermarkProps = computed(() => {
21+
const props: WatermarkProps = {
22+
content: themeStore.watermark.text,
23+
width: 120,
24+
height: 120,
25+
font: {
26+
fontSize: 16
27+
},
28+
offset: [12, 60],
29+
rotate: -15,
30+
zIndex: 9999
31+
};
32+
33+
return props;
34+
});
1835
</script>
1936

2037
<template>
2138
<ConfigProvider :theme="themeStore.antdTheme" :locale="antdLocale">
2239
<AppProvider>
2340
<RouterView class="bg-layout" />
41+
<AWatermark
42+
v-if="themeStore.watermark.visible"
43+
v-bind="watermarkProps"
44+
class="pointer-events-none absolute-lt! size-full"
45+
/>
2446
</AppProvider>
2547
</ConfigProvider>
2648
</template>

src/layouts/modules/theme-drawer/modules/page-fun.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra
9797
>
9898
<ASwitch v-model:checked="themeStore.footer.right" />
9999
</SettingItem>
100+
<SettingItem v-if="themeStore.watermark" key="8" :label="$t('theme.watermark.visible')">
101+
<ASwitch v-model:checked="themeStore.watermark.visible" />
102+
</SettingItem>
103+
<SettingItem v-if="themeStore.watermark?.visible" key="8-1" :label="$t('theme.watermark.text')">
104+
<AInput v-model:value="themeStore.watermark.text" placeholder="SoybeanAdmin" class="w-120px" />
105+
</SettingItem>
100106
</TransitionGroup>
101107
</template>
102108

src/locales/langs/en-us.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ const local: App.I18n.Schema = {
133133
height: 'Footer Height',
134134
right: 'Right Footer'
135135
},
136+
watermark: {
137+
visible: 'Watermark Full Screen Visible',
138+
text: 'Watermark Text'
139+
},
136140
themeDrawerTitle: 'Theme Configuration',
137141
pageFunTitle: 'Page Function',
138142
configOperation: {

src/locales/langs/zh-cn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ const local: App.I18n.Schema = {
133133
height: '底部高度',
134134
right: '底部局右'
135135
},
136+
watermark: {
137+
visible: '显示全屏水印',
138+
text: '水印文本'
139+
},
136140
themeDrawerTitle: '主题配置',
137141
pageFunTitle: '页面功能',
138142
configOperation: {

src/theme/settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export const themeSettings: App.Theme.ThemeSetting = {
4949
height: 48,
5050
right: true
5151
},
52+
watermark: {
53+
visible: false,
54+
text: 'SoybeanAdmin'
55+
},
5256
tokens: {
5357
light: {
5458
colors: {

src/typings/app.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ declare namespace App {
9595
/** Whether float the footer to the right when the layout is 'horizontal-mix' */
9696
right: boolean;
9797
};
98+
/** Watermark */
99+
watermark: {
100+
/** Whether to show the watermark */
101+
visible: boolean;
102+
/** Watermark text */
103+
text: string;
104+
};
98105
/** define some theme settings tokens, will transform to css variables */
99106
tokens: {
100107
light: ThemeSettingToken;
@@ -371,6 +378,10 @@ declare namespace App {
371378
height: string;
372379
right: string;
373380
};
381+
watermark: {
382+
visible: string;
383+
text: string;
384+
};
374385
themeDrawerTitle: string;
375386
pageFunTitle: string;
376387
configOperation: {

src/typings/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare module 'vue' {
4747
ATag: typeof import('ant-design-vue/es')['Tag']
4848
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
4949
ATree: typeof import('ant-design-vue/es')['Tree']
50+
AWatermark: typeof import('ant-design-vue/es')['Watermark']
5051
BetterScroll: typeof import('./../components/custom/better-scroll.vue')['default']
5152
ButtonIcon: typeof import('./../components/custom/button-icon.vue')['default']
5253
CountTo: typeof import('./../components/custom/count-to.vue')['default']

0 commit comments

Comments
 (0)