|
@@ -1,7 +1,8 @@
|
|
|
import { PageLoading } from '@ant-design/pro-layout';
|
|
|
import { history, useModel } from 'umi';
|
|
|
import { checkToken, reFreshCheckToken } from '@/services/ant-design-pro/environment';
|
|
|
-import userData from '@/config/user';
|
|
|
+import { projectId } from '@/config/api.js';
|
|
|
+import UserStorage from '@/config/user';
|
|
|
const loginPath = '/noAuth';
|
|
|
|
|
|
/** 获取用户信息比较慢的时候会展示一个 loading */
|
|
@@ -44,12 +45,14 @@ export async function getInitialState(): Promise<{
|
|
|
//if (!access_token) return; //随后去掉
|
|
|
//验证acces_token 获取用户数据
|
|
|
const res = await checkToken({ token: access_token });
|
|
|
+
|
|
|
var resUser = res.data;
|
|
|
} catch (err) {
|
|
|
history.push(loginPath);
|
|
|
}
|
|
|
if (resUser) {
|
|
|
- var userObj = userData.getInstance();
|
|
|
+ //获取用户信息 并储存
|
|
|
+ var userObj = UserStorage.getInstance();
|
|
|
userObj.setUser(resUser);
|
|
|
return resUser;
|
|
|
} else {
|
|
@@ -58,7 +61,19 @@ export async function getInitialState(): Promise<{
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const currentUser = await fetchUser();
|
|
|
+ let currentUser = {};
|
|
|
+ //之江项目 验证token
|
|
|
+ if (projectId == 'Pj3301100002') {
|
|
|
+ currentUser = await fetchUser();
|
|
|
+ } else {
|
|
|
+ let tempUser = {
|
|
|
+ name: '行政测试',
|
|
|
+ phone: '17611228068',
|
|
|
+ id: '9a1ecfbacb6b4f249bf2dd3ec7793ead',
|
|
|
+ };
|
|
|
+ var userObj = UserStorage.getInstance();
|
|
|
+ userObj.setUser(tempUser);
|
|
|
+ }
|
|
|
|
|
|
const reFreshUser = async () => {
|
|
|
refresh_token = localStorage.getItem('refresh_token');
|