Skip to content

Commit

Permalink
!88 解决登录成功后水印不更新问题
Browse files Browse the repository at this point in the history
Merge pull request !88 from wen/dev
  • Loading branch information
Aeizzz authored and gitee-org committed Aug 23, 2024
2 parents daaf6a2 + d57a423 commit af0de07
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,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') });
Expand All @@ -69,9 +73,10 @@ onMounted(() => {
}
});
});
// 页面销毁时,关闭监听布局配置/i18n监听
// 页面销毁时,关闭监听布局配置/i18n监听/更新水印
onUnmounted(() => {
mittBus.off('openSetingsDrawer', () => {});
mittBus.off('updateWartermark', () => {});
});
// 监听路由的变化,设置网站标题
watch(
Expand Down
1 change: 1 addition & 0 deletions src/layout/navBars/breadcrumb/setings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ onUnmounted(() => {
// 暴露变量
defineExpose({
openDrawer,
onWartermarkChange,
});
</script>

Expand Down
2 changes: 2 additions & 0 deletions src/types/mitt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @method openShareTagsView 布局设置弹窗,开启 TagsView 共用
* @method onTagsViewRefreshRouterView tagsview 刷新界面
* @method onCurrentContextmenuClick tagsview 右键菜单每项点击时
* @method updateWartermark 更新水印显示内容
*/
declare type MittType<T = any> = {
openSetingsDrawer?: string;
Expand All @@ -23,6 +24,7 @@ declare type MittType<T = any> = {
openShareTagsView?: string;
onTagsViewRefreshRouterView?: T;
onCurrentContextmenuClick?: T;
updateWartermark?: T;
};

// mitt 参数类型定义
Expand Down
3 changes: 3 additions & 0 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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'));
Expand Down Expand Up @@ -71,6 +72,8 @@ const signInSuccess = async () => {
useMessage().wraning('抱歉,您没有登录权限');
Session.clear();
} else {
// 重新加载水印
mittBus.emit('updateWartermark');
// 初始化登录成功时间问候语
let currentTimeInfo = formatAxis(new Date());
if (route.query?.redirect) {
Expand Down

0 comments on commit af0de07

Please sign in to comment.