|
@@ -4,6 +4,7 @@ import RightContent from '@/components/RightContent';
|
4
|
4
|
import Footer from '@/components/Footer';
|
5
|
5
|
import { currentUser as queryCurrentUser } from './services/user';
|
6
|
6
|
import { requestConfig } from '@/utils/request';
|
|
7
|
+import myPath from './utils/myPath';
|
7
|
8
|
|
8
|
9
|
const isDev = process.env.NODE_ENV === 'development';
|
9
|
10
|
let loginPath = '/user/orgLogin';
|
|
@@ -16,16 +17,11 @@ export const initialStateConfig = {
|
16
|
17
|
* @see https://umijs.org/zh-CN/plugins/plugin-initial-state
|
17
|
18
|
* */
|
18
|
19
|
export async function getInitialState() {
|
19
|
|
- let role=localStorage.getItem('roleAlias');
|
20
|
20
|
const fetchUserInfo = async () => {
|
21
|
21
|
try {
|
22
|
22
|
return await queryCurrentUser();
|
23
|
|
- } catch (error) {
|
24
|
|
- if(role=='admin'){
|
25
|
|
- history.push('/user/login');
|
26
|
|
- }else {
|
27
|
|
- history.push(loginPath);
|
28
|
|
- }
|
|
23
|
+ } catch (error) {
|
|
24
|
+ history.push(myPath());
|
29
|
25
|
}
|
30
|
26
|
|
31
|
27
|
return undefined;
|
|
@@ -58,20 +54,15 @@ export const layout = ({ initialState }) => {
|
58
|
54
|
footerRender: () => <Footer />,
|
59
|
55
|
onPageChange: () => {
|
60
|
56
|
const { location } = history; // 如果没有登录,重定向到 login
|
61
|
|
- let role=localStorage.getItem('roleAlias');
|
62
|
57
|
if (!initialState?.currentUser &&
|
63
|
58
|
location.pathname !== loginPath &&
|
64
|
59
|
location.pathname !== '/user/login') {
|
65
|
|
- if(role=='admin'){
|
66
|
|
- history.push('/user/login');
|
67
|
|
- }else {
|
68
|
|
- history.push(loginPath);
|
69
|
|
- }
|
|
60
|
+ history.push(myPath());
|
70
|
61
|
}
|
71
|
62
|
},
|
72
|
63
|
menuHeaderRender: undefined,
|
73
|
64
|
// 自定义 403 页面
|
74
|
|
- unAccessible: history.push('/'),
|
|
65
|
+ // unAccessible: history.push('/'),
|
75
|
66
|
...initialState?.settings,
|
76
|
67
|
};
|
77
|
68
|
};
|