From 6ad404ab326cc5c43df6309163e0e309a1891d7a Mon Sep 17 00:00:00 2001 From: paynezhuang Date: Mon, 29 Jul 2024 22:09:18 +0800 Subject: [PATCH] feat(projects): add full screen watermark. close#571 --- src/App.vue | 17 +++++++++++++++++ .../modules/theme-drawer/modules/page-fun.vue | 13 +++++++++++++ src/locales/langs/en-us.ts | 4 ++++ src/locales/langs/zh-cn.ts | 4 ++++ src/theme/settings.ts | 4 ++++ src/typings/app.d.ts | 11 +++++++++++ src/typings/components.d.ts | 1 + 7 files changed, 54 insertions(+) diff --git a/src/App.vue b/src/App.vue index 223533079..35f65f69c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,6 +21,22 @@ const naiveLocale = computed(() => { const naiveDateLocale = computed(() => { return naiveDateLocales[appStore.locale]; }); + +const watermarkProps = computed(() => { + return { + content: themeStore.watermark.text, + cross: true, + fullscreen: true, + fontSize: 16, + lineHeight: 16, + width: 384, + height: 384, + xOffset: 12, + yOffset: 60, + rotate: -15, + zIndex: 9999 + }; +}); diff --git a/src/layouts/modules/theme-drawer/modules/page-fun.vue b/src/layouts/modules/theme-drawer/modules/page-fun.vue index 8f80994f5..4595c8a5f 100644 --- a/src/layouts/modules/theme-drawer/modules/page-fun.vue +++ b/src/layouts/modules/theme-drawer/modules/page-fun.vue @@ -101,6 +101,19 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra > + + + + + + diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 26441217f..8b3318599 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -135,6 +135,10 @@ const local: App.I18n.Schema = { height: 'Footer Height', right: 'Right Footer' }, + watermark: { + visible: 'Watermark Full Screen Visible', + text: 'Watermark Text' + }, themeDrawerTitle: 'Theme Configuration', pageFunTitle: 'Page Function', configOperation: { diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 95f1e665d..630b29105 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -135,6 +135,10 @@ const local: App.I18n.Schema = { height: '底部高度', right: '底部局右' }, + watermark: { + visible: '显示全屏水印', + text: '水印文本' + }, themeDrawerTitle: '主题配置', pageFunTitle: '页面功能', configOperation: { diff --git a/src/theme/settings.ts b/src/theme/settings.ts index 74c1c885a..397e1eda8 100644 --- a/src/theme/settings.ts +++ b/src/theme/settings.ts @@ -49,6 +49,10 @@ export const themeSettings: App.Theme.ThemeSetting = { height: 48, right: true }, + watermark: { + visible: true, + text: 'SoybeanAdmin' + }, tokens: { light: { colors: { diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index 728a2c7f2..d1a7f5992 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -95,6 +95,13 @@ declare namespace App { /** Whether float the footer to the right when the layout is 'horizontal-mix' */ right: boolean; }; + /** Watermark */ + watermark: { + /** Whether to show the watermark */ + visible: boolean; + /** Watermark text */ + text: string; + }; /** define some theme settings tokens, will transform to css variables */ tokens: { light: ThemeSettingToken; @@ -375,6 +382,10 @@ declare namespace App { height: string; right: string; }; + watermark: { + visible: string; + text: string; + }; themeDrawerTitle: string; pageFunTitle: string; configOperation: { diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 1067e4db1..1b0ebf024 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -84,6 +84,7 @@ declare module 'vue' { NThing: typeof import('naive-ui')['NThing'] NTooltip: typeof import('naive-ui')['NTooltip'] NTree: typeof import('naive-ui')['NTree'] + NWatermark: typeof import('naive-ui')['NWatermark'] PinToggler: typeof import('./../components/common/pin-toggler.vue')['default'] ReloadButton: typeof import('./../components/common/reload-button.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink']