mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
fix(水印): 解决登录成功后水印不更新问题-改为mittbus
This commit is contained in:
parent
816035306b
commit
d57a423877
13
src/App.vue
13
src/App.vue
@ -16,12 +16,6 @@ import { Local, Session } from '/@/utils/storage';
|
|||||||
import mittBus from '/@/utils/mitt';
|
import mittBus from '/@/utils/mitt';
|
||||||
import setIntroduction from '/@/utils/setIconfont';
|
import setIntroduction from '/@/utils/setIconfont';
|
||||||
|
|
||||||
provide('onWartermarkChange', () => {
|
|
||||||
if (settingRef.value) {
|
|
||||||
settingRef.value.onWartermarkChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
||||||
const Setings = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/setings.vue'));
|
const Setings = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/setings.vue'));
|
||||||
@ -64,6 +58,10 @@ onMounted(() => {
|
|||||||
mittBus.on('openSetingsDrawer', () => {
|
mittBus.on('openSetingsDrawer', () => {
|
||||||
settingRef.value.openDrawer();
|
settingRef.value.openDrawer();
|
||||||
});
|
});
|
||||||
|
// 监听登录成功后重新加载水印
|
||||||
|
mittBus.on('updateWartermark', () => {
|
||||||
|
settingRef.value.onWartermarkChange();
|
||||||
|
});
|
||||||
// 获取缓存中的布局配置
|
// 获取缓存中的布局配置
|
||||||
if (Local.get('themeConfig')) {
|
if (Local.get('themeConfig')) {
|
||||||
storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
||||||
@ -75,9 +73,10 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// 页面销毁时,关闭监听布局配置/i18n监听
|
// 页面销毁时,关闭监听布局配置/i18n监听/更新水印
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
mittBus.off('openSetingsDrawer', () => {});
|
mittBus.off('openSetingsDrawer', () => {});
|
||||||
|
mittBus.off('updateWartermark', () => {});
|
||||||
});
|
});
|
||||||
// 监听路由的变化,设置网站标题
|
// 监听路由的变化,设置网站标题
|
||||||
watch(
|
watch(
|
||||||
|
2
src/types/mitt.d.ts
vendored
2
src/types/mitt.d.ts
vendored
@ -11,6 +11,7 @@
|
|||||||
* @method openShareTagsView 布局设置弹窗,开启 TagsView 共用
|
* @method openShareTagsView 布局设置弹窗,开启 TagsView 共用
|
||||||
* @method onTagsViewRefreshRouterView tagsview 刷新界面
|
* @method onTagsViewRefreshRouterView tagsview 刷新界面
|
||||||
* @method onCurrentContextmenuClick tagsview 右键菜单每项点击时
|
* @method onCurrentContextmenuClick tagsview 右键菜单每项点击时
|
||||||
|
* @method updateWartermark 更新水印显示内容
|
||||||
*/
|
*/
|
||||||
declare type MittType<T = any> = {
|
declare type MittType<T = any> = {
|
||||||
openSetingsDrawer?: string;
|
openSetingsDrawer?: string;
|
||||||
@ -23,6 +24,7 @@ declare type MittType<T = any> = {
|
|||||||
openShareTagsView?: string;
|
openShareTagsView?: string;
|
||||||
onTagsViewRefreshRouterView?: T;
|
onTagsViewRefreshRouterView?: T;
|
||||||
onCurrentContextmenuClick?: T;
|
onCurrentContextmenuClick?: T;
|
||||||
|
updateWartermark?: T;
|
||||||
};
|
};
|
||||||
|
|
||||||
// mitt 参数类型定义
|
// mitt 参数类型定义
|
||||||
|
@ -40,13 +40,13 @@ import { formatAxis } from '/@/utils/formatTime';
|
|||||||
import { useMessage } from '/@/hooks/message';
|
import { useMessage } from '/@/hooks/message';
|
||||||
import { Session } from '/@/utils/storage';
|
import { Session } from '/@/utils/storage';
|
||||||
import { initBackEndControlRoutes } from '/@/router/backEnd';
|
import { initBackEndControlRoutes } from '/@/router/backEnd';
|
||||||
|
import mittBus from '/@/utils/mitt';
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const Password = defineAsyncComponent(() => import('./component/password.vue'));
|
const Password = defineAsyncComponent(() => import('./component/password.vue'));
|
||||||
const Mobile = defineAsyncComponent(() => import('./component/mobile.vue'));
|
const Mobile = defineAsyncComponent(() => import('./component/mobile.vue'));
|
||||||
const Register = defineAsyncComponent(() => import('./component/register.vue'));
|
const Register = defineAsyncComponent(() => import('./component/register.vue'));
|
||||||
|
|
||||||
const onWartermarkChange = inject<() => void>('onWartermarkChange');
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const storesThemeConfig = useThemeConfig();
|
const storesThemeConfig = useThemeConfig();
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
@ -73,7 +73,7 @@ const signInSuccess = async () => {
|
|||||||
Session.clear();
|
Session.clear();
|
||||||
} else {
|
} else {
|
||||||
// 重新加载水印
|
// 重新加载水印
|
||||||
onWartermarkChange && onWartermarkChange()
|
mittBus.emit('updateWartermark');
|
||||||
// 初始化登录成功时间问候语
|
// 初始化登录成功时间问候语
|
||||||
let currentTimeInfo = formatAxis(new Date());
|
let currentTimeInfo = formatAxis(new Date());
|
||||||
if (route.query?.redirect) {
|
if (route.query?.redirect) {
|
||||||
|
Loading…
Reference in New Issue
Block a user