From 52a1b54ea8a134aeb82a8ce724d20ffd1a717bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9?= <19910352037@163.com> Date: Mon, 26 Aug 2024 09:29:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B0=B4=E5=8D=B0):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B0=B4=E5=8D=B0=E9=80=9A=E7=9F=A5=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 7 +------ src/layout/navBars/breadcrumb/setings.vue | 6 +++++- src/stores/userInfo.ts | 3 +++ src/views/login/index.vue | 3 --- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9d7c32a0..eedd3277 100644 --- a/src/App.vue +++ b/src/App.vue @@ -58,10 +58,6 @@ onMounted(() => { mittBus.on('openSetingsDrawer', () => { settingRef.value.openDrawer(); }); - // 监听登录成功后重新加载水印 - mittBus.on('updateWartermark', () => { - settingRef.value.onWartermarkChange(); - }); // 获取缓存中的布局配置 if (Local.get('themeConfig')) { storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') }); @@ -73,10 +69,9 @@ onMounted(() => { } }); }); -// 页面销毁时,关闭监听布局配置/i18n监听/更新水印 +// 页面销毁时,关闭监听布局配置/i18n监听 onUnmounted(() => { mittBus.off('openSetingsDrawer', () => {}); - mittBus.off('updateWartermark', () => {}); }); // 监听路由的变化,设置网站标题 watch( diff --git a/src/layout/navBars/breadcrumb/setings.vue b/src/layout/navBars/breadcrumb/setings.vue index c94218fa..09232268 100644 --- a/src/layout/navBars/breadcrumb/setings.vue +++ b/src/layout/navBars/breadcrumb/setings.vue @@ -653,6 +653,10 @@ onMounted(() => { initLayoutChangeFun(); state.isMobile = other.isMobile(); }); + // 监听登录成功后重新加载水印 + mittBus.on('updateWartermark', () => { + onWartermarkChange(); + }); setTimeout(() => { // 默认样式 onColorPickerChange(); @@ -673,12 +677,12 @@ onMounted(() => { }); onUnmounted(() => { mittBus.off('layoutMobileResize', () => {}); + mittBus.off('updateWartermark', () => {}); }); // 暴露变量 defineExpose({ openDrawer, - onWartermarkChange, }); diff --git a/src/stores/userInfo.ts b/src/stores/userInfo.ts index cdf00eb8..c2f20c46 100644 --- a/src/stores/userInfo.ts +++ b/src/stores/userInfo.ts @@ -3,6 +3,7 @@ import { Session } from '/@/utils/storage'; import { getUserInfo, login, loginByMobile, loginBySocial, refreshTokenApi } from '/@/api/login/index'; import other from '/@/utils/other'; import { useMessage } from '/@/hooks/message'; +import mittBus from '/@/utils/mitt'; /** * @function useUserInfo @@ -130,6 +131,8 @@ export const useUserInfo = defineStore('userInfo', { authBtnList: res.data.permissions, }; this.userInfos = userInfo; + // 重新加载水印 + mittBus.emit('updateWartermark'); }); }, }, diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 0a2138dc..3d4ee93e 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -40,7 +40,6 @@ 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')); @@ -72,8 +71,6 @@ const signInSuccess = async () => { useMessage().wraning('抱歉,您没有登录权限'); Session.clear(); } else { - // 重新加载水印 - mittBus.emit('updateWartermark'); // 初始化登录成功时间问候语 let currentTimeInfo = formatAxis(new Date()); if (route.query?.redirect) {