Skip to content

Commit ea8aa6c

Browse files
authored
feat(projects): add full screen watermark. close#571 (#573)
1 parent 4dde4c2 commit ea8aa6c

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed

src/App.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ const naiveLocale = computed(() => {
2121
const naiveDateLocale = computed(() => {
2222
return naiveDateLocales[appStore.locale];
2323
});
24+
25+
const watermarkProps = computed(() => {
26+
return {
27+
content: themeStore.watermark.text,
28+
cross: true,
29+
fullscreen: true,
30+
fontSize: 16,
31+
lineHeight: 16,
32+
width: 384,
33+
height: 384,
34+
xOffset: 12,
35+
yOffset: 60,
36+
rotate: -15,
37+
zIndex: 9999
38+
};
39+
});
2440
</script>
2541

2642
<template>
@@ -33,6 +49,7 @@ const naiveDateLocale = computed(() => {
3349
>
3450
<AppProvider>
3551
<RouterView class="bg-layout" />
52+
<NWatermark v-if="themeStore.watermark.visible" v-bind="watermarkProps" />
3653
</AppProvider>
3754
</NConfigProvider>
3855
</template>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra
101101
>
102102
<NSwitch v-model:value="themeStore.footer.right" />
103103
</SettingItem>
104+
<SettingItem key="8" :label="$t('theme.watermark.visible')">
105+
<NSwitch v-model:value="themeStore.watermark.visible" />
106+
</SettingItem>
107+
<SettingItem v-if="themeStore.watermark.visible" key="8-1" :label="$t('theme.watermark.text')">
108+
<NInput
109+
v-model:value="themeStore.watermark.text"
110+
autosize
111+
type="text"
112+
size="small"
113+
class="w-120px"
114+
placeholder="SoybeanAdmin"
115+
/>
116+
</SettingItem>
104117
</TransitionGroup>
105118
</template>
106119

src/locales/langs/en-us.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ const local: App.I18n.Schema = {
135135
height: 'Footer Height',
136136
right: 'Right Footer'
137137
},
138+
watermark: {
139+
visible: 'Watermark Full Screen Visible',
140+
text: 'Watermark Text'
141+
},
138142
themeDrawerTitle: 'Theme Configuration',
139143
pageFunTitle: 'Page Function',
140144
configOperation: {

src/locales/langs/zh-cn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ const local: App.I18n.Schema = {
135135
height: '底部高度',
136136
right: '底部局右'
137137
},
138+
watermark: {
139+
visible: '显示全屏水印',
140+
text: '水印文本'
141+
},
138142
themeDrawerTitle: '主题配置',
139143
pageFunTitle: '页面功能',
140144
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;
@@ -375,6 +382,10 @@ declare namespace App {
375382
height: string;
376383
right: string;
377384
};
385+
watermark: {
386+
visible: string;
387+
text: string;
388+
};
378389
themeDrawerTitle: string;
379390
pageFunTitle: string;
380391
configOperation: {

src/typings/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ declare module 'vue' {
8484
NThing: typeof import('naive-ui')['NThing']
8585
NTooltip: typeof import('naive-ui')['NTooltip']
8686
NTree: typeof import('naive-ui')['NTree']
87+
NWatermark: typeof import('naive-ui')['NWatermark']
8788
PinToggler: typeof import('./../components/common/pin-toggler.vue')['default']
8889
ReloadButton: typeof import('./../components/common/reload-button.vue')['default']
8990
RouterLink: typeof import('vue-router')['RouterLink']

0 commit comments

Comments
 (0)