From d57a423877e2b7859f2ee70d25af24fb35cba185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9?= <19910352037@163.com> Date: Fri, 23 Aug 2024 10:26:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B0=B4=E5=8D=B0):=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F=E5=90=8E=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98-=E6=94=B9?= =?UTF-8?q?=E4=B8=BAmittbus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 13 ++++++------- src/types/mitt.d.ts | 2 ++ src/views/login/index.vue | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/App.vue b/src/App.vue index 79690c18..9d7c32a0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,12 +16,6 @@ import { Local, Session } from '/@/utils/storage'; import mittBus from '/@/utils/mitt'; import setIntroduction from '/@/utils/setIconfont'; -provide('onWartermarkChange', () => { - if (settingRef.value) { - settingRef.value.onWartermarkChange(); - } -}); - // 引入组件 const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue')); const Setings = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/setings.vue')); @@ -64,6 +58,10 @@ onMounted(() => { mittBus.on('openSetingsDrawer', () => { settingRef.value.openDrawer(); }); + // 监听登录成功后重新加载水印 + mittBus.on('updateWartermark', () => { + settingRef.value.onWartermarkChange(); + }); // 获取缓存中的布局配置 if (Local.get('themeConfig')) { storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') }); @@ -75,9 +73,10 @@ onMounted(() => { } }); }); -// 页面销毁时,关闭监听布局配置/i18n监听 +// 页面销毁时,关闭监听布局配置/i18n监听/更新水印 onUnmounted(() => { mittBus.off('openSetingsDrawer', () => {}); + mittBus.off('updateWartermark', () => {}); }); // 监听路由的变化,设置网站标题 watch( diff --git a/src/types/mitt.d.ts b/src/types/mitt.d.ts index b68b80df..04ade16b 100644 --- a/src/types/mitt.d.ts +++ b/src/types/mitt.d.ts @@ -11,6 +11,7 @@ * @method openShareTagsView 布局设置弹窗,开启 TagsView 共用 * @method onTagsViewRefreshRouterView tagsview 刷新界面 * @method onCurrentContextmenuClick tagsview 右键菜单每项点击时 + * @method updateWartermark 更新水印显示内容 */ declare type MittType = { openSetingsDrawer?: string; @@ -23,6 +24,7 @@ declare type MittType = { openShareTagsView?: string; onTagsViewRefreshRouterView?: T; onCurrentContextmenuClick?: T; + updateWartermark?: T; }; // mitt 参数类型定义 diff --git a/src/views/login/index.vue b/src/views/login/index.vue index b01fbce2..0a2138dc 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -40,13 +40,13 @@ import { formatAxis } from '/@/utils/formatTime'; import { useMessage } from '/@/hooks/message'; import { Session } from '/@/utils/storage'; import { initBackEndControlRoutes } from '/@/router/backEnd'; +import mittBus from '/@/utils/mitt'; // 引入组件 const Password = defineAsyncComponent(() => import('./component/password.vue')); const Mobile = defineAsyncComponent(() => import('./component/mobile.vue')); const Register = defineAsyncComponent(() => import('./component/register.vue')); -const onWartermarkChange = inject<() => void>('onWartermarkChange'); // 定义变量内容 const storesThemeConfig = useThemeConfig(); const { themeConfig } = storeToRefs(storesThemeConfig); @@ -73,7 +73,7 @@ const signInSuccess = async () => { Session.clear(); } else { // 重新加载水印 - onWartermarkChange && onWartermarkChange() + mittBus.emit('updateWartermark'); // 初始化登录成功时间问候语 let currentTimeInfo = formatAxis(new Date()); if (route.query?.redirect) {