Skip to content

Commit 6425d7e

Browse files
committed
fix: 修复Token失效后登录页渲染异常
1 parent edec77f commit 6425d7e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/layouts/BasicLayout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import MultiTab from '@/components/MultiTab';
1616
import { KeepAlive as ReactKeepAlive } from 'react-activation';
1717
import Notify from '@/utils/NotifyUtils';
1818
import Header from '@/components/Header';
19+
import { useAliveController } from 'react-activation';
1920

2021
export type BasicLayoutProps = {
2122
breadcrumbNameMap: Record<string, MenuDataItem>;
@@ -44,6 +45,9 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
4445
route,
4546
} = props;
4647

48+
const { clear } = useAliveController();
49+
Notify.setCleanCache(clear);
50+
4751
const { routeArray, firstPath, load, setLoad } = useModel('dynamic-route');
4852
const { initialState } = useModel('@@initialState');
4953
const { isContentFull } = useModel('full-screen');

src/utils/NotifyUtils.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { Token, User } from './Ballcat';
77

88
export type NotifyProps = { id: string; content: string; title: string };
99
let logoutModal: any;
10+
let cleanCache: any = () => {};
1011

1112
const logoutHandler = () => {
12-
Modal.destroyAll();
1313
User.clean();
1414
logoutModal = undefined;
15+
cleanCache();
1516
const { pathname } = history.location;
1617
history.replace(`/user/login?redirect=${pathname}`);
1718
};
@@ -24,13 +25,16 @@ const readNotice = (id: string) => {
2425
};
2526

2627
const Notify = {
28+
setCleanCache: (clean: any) => {
29+
cleanCache = clean;
30+
},
2731
preview: (props: NotifyProps) => {
2832
Notify.notice({ ...props, id: '' });
2933
},
3034
notice: ({ id, content, title }: NotifyProps) => {
3135
Modal.info({
3236
title,
33-
content: <div dangerouslySetInnerHTML={{ __html: content }}></div>,
37+
content: <div dangerouslySetInnerHTML={{ __html: content }} />,
3438
width: 800,
3539
icon: (
3640
<NotificationOutlined
@@ -56,6 +60,8 @@ const Notify = {
5660
return;
5761
}
5862
Token.clean();
63+
Modal.destroyAll();
64+
5965
logoutModal = Modal.info({
6066
title: I18n.text('notify.logout.title'),
6167
content: I18n.text('notify.logout.content'),
@@ -64,6 +70,7 @@ const Notify = {
6470
okText: I18n.text('notify.logout.okText'),
6571
onOk: () => logoutHandler(),
6672
onCancel: () => logoutHandler(),
73+
zIndex: 99999999,
6774
});
6875
},
6976
};

0 commit comments

Comments
 (0)