mirror of
https://gitee.com/honghuangdc/soybean-admin-element-plus.git
synced 2025-12-30 10:22:25 +00:00
feat(projects): ✨ add configurable user name watermark option.
* fix(types): 🐛 The environment variable VITE_ICON_LOCAL_PREFIX has the wrong type. * feat(projects): ✨ add configurable user name watermark option
This commit is contained in:
10
src/App.vue
10
src/App.vue
@@ -3,20 +3,26 @@ import { computed } from 'vue';
|
||||
import type { WatermarkProps } from 'element-plus';
|
||||
import { useAppStore } from './store/modules/app';
|
||||
import { useThemeStore } from './store/modules/theme';
|
||||
import { useAuthStore } from './store/modules/auth';
|
||||
import { UILocales } from './locales/ui';
|
||||
|
||||
defineOptions({ name: 'App' });
|
||||
|
||||
const appStore = useAppStore();
|
||||
const themeStore = useThemeStore();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const locale = computed(() => {
|
||||
return UILocales[appStore.locale];
|
||||
});
|
||||
|
||||
const watermarkProps = computed<WatermarkProps>(() => {
|
||||
const content =
|
||||
themeStore.watermark.enableUserName && authStore.userInfo.userName
|
||||
? authStore.userInfo.userName
|
||||
: themeStore.watermark.text;
|
||||
|
||||
return {
|
||||
content: themeStore.watermark.visible ? themeStore.watermark.text || 'SoybeanAdmin' : '',
|
||||
content: themeStore.watermark.visible ? content : '',
|
||||
cross: true,
|
||||
fontSize: 16,
|
||||
lineHeight: 16,
|
||||
|
||||
@@ -123,7 +123,10 @@ const isWrapperScrollMode = computed(() => themeStore.layout.scrollMode === 'wra
|
||||
<SettingItem key="8" :label="$t('theme.watermark.visible')">
|
||||
<ElSwitch v-model="themeStore.watermark.visible" />
|
||||
</SettingItem>
|
||||
<SettingItem v-if="themeStore.watermark.visible" key="8-1" :label="$t('theme.watermark.text')">
|
||||
<SettingItem v-if="themeStore.watermark.visible" key="8-1" :label="$t('theme.watermark.enableUserName')">
|
||||
<ElSwitch v-model="themeStore.watermark.enableUserName" />
|
||||
</SettingItem>
|
||||
<SettingItem v-if="themeStore.watermark.visible" key="8-2" :label="$t('theme.watermark.text')">
|
||||
<ElInput
|
||||
v-model="themeStore.watermark.text"
|
||||
autosize
|
||||
|
||||
@@ -143,7 +143,8 @@ const local: App.I18n.Schema = {
|
||||
},
|
||||
watermark: {
|
||||
visible: 'Watermark Full Screen Visible',
|
||||
text: 'Watermark Text'
|
||||
text: 'Watermark Text',
|
||||
enableUserName: 'Enable User Name Watermark'
|
||||
},
|
||||
themeDrawerTitle: 'Theme Configuration',
|
||||
pageFunTitle: 'Page Function',
|
||||
|
||||
@@ -143,7 +143,8 @@ const local: App.I18n.Schema = {
|
||||
},
|
||||
watermark: {
|
||||
visible: '显示全屏水印',
|
||||
text: '水印文本'
|
||||
text: '水印文本',
|
||||
enableUserName: '启用用户名水印'
|
||||
},
|
||||
themeDrawerTitle: '主题配置',
|
||||
pageFunTitle: '页面功能',
|
||||
|
||||
@@ -58,7 +58,8 @@ export const themeSettings: App.Theme.ThemeSetting = {
|
||||
},
|
||||
watermark: {
|
||||
visible: false,
|
||||
text: 'SoybeanAdmin'
|
||||
text: 'SoybeanAdmin',
|
||||
enableUserName: false
|
||||
},
|
||||
tokens: {
|
||||
light: {
|
||||
|
||||
3
src/typings/app.d.ts
vendored
3
src/typings/app.d.ts
vendored
@@ -113,6 +113,8 @@ declare namespace App {
|
||||
visible: boolean;
|
||||
/** Watermark text */
|
||||
text: string;
|
||||
/** Whether to use user name as watermark text */
|
||||
enableUserName: boolean;
|
||||
};
|
||||
/** define some theme settings tokens, will transform to css variables */
|
||||
tokens: {
|
||||
@@ -403,6 +405,7 @@ declare namespace App {
|
||||
watermark: {
|
||||
visible: string;
|
||||
text: string;
|
||||
enableUserName: string;
|
||||
};
|
||||
themeDrawerTitle: string;
|
||||
pageFunTitle: string;
|
||||
|
||||
2
src/typings/vite-env.d.ts
vendored
2
src/typings/vite-env.d.ts
vendored
@@ -25,7 +25,7 @@ declare namespace Env {
|
||||
*
|
||||
* This prefix is start with the icon prefix
|
||||
*/
|
||||
readonly VITE_ICON_LOCAL_PREFIX: 'local-icon';
|
||||
readonly VITE_ICON_LOCAL_PREFIX: 'icon-local';
|
||||
/** backend service base url */
|
||||
readonly VITE_SERVICE_BASE_URL: string;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user