|
@@ -1,6 +1,6 @@
|
|
-import vueStore from '@/store'
|
|
|
|
-import { sessionStore } from '@/store/sessionStore'
|
|
|
|
-import { logicConfig } from '@/logicConfig'
|
|
|
|
|
|
+import vueStore from "@/store";
|
|
|
|
+import { sessionStore } from "@/store/sessionStore";
|
|
|
|
+import { logicConfig } from "@/logicConfig";
|
|
import { userController } from "@/controller/userController";
|
|
import { userController } from "@/controller/userController";
|
|
|
|
|
|
export class authUtils {
|
|
export class authUtils {
|
|
@@ -13,7 +13,7 @@ export class authUtils {
|
|
async routerBeforeEach(to, from, next) {
|
|
async routerBeforeEach(to, from, next) {
|
|
//访问登录页面时直接显示
|
|
//访问登录页面时直接显示
|
|
if (to.path == logicConfig.routerNameConfig.loginRouteName) {
|
|
if (to.path == logicConfig.routerNameConfig.loginRouteName) {
|
|
- !vueStore.state.fromPath ? vueStore.commit('updateFromPath', '/') : '';
|
|
|
|
|
|
+ !vueStore.state.fromPath ? vueStore.commit("updateFromPath", "/") : "";
|
|
next();
|
|
next();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -21,7 +21,7 @@ export class authUtils {
|
|
//如果sessionStore里没有用户ID,说明用户没有登录,此时跳转到登录页
|
|
//如果sessionStore里没有用户ID,说明用户没有登录,此时跳转到登录页
|
|
var userId = sessionStore.userId;
|
|
var userId = sessionStore.userId;
|
|
if (!userId) {
|
|
if (!userId) {
|
|
- vueStore.commit('updateFromPath', to.path);
|
|
|
|
|
|
+ vueStore.commit("updateFromPath", to.path);
|
|
next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -29,23 +29,21 @@ export class authUtils {
|
|
//如果vueStore里存在用户ID,说明已经缓存的有用户信息,不需要再次获取
|
|
//如果vueStore里存在用户ID,说明已经缓存的有用户信息,不需要再次获取
|
|
if (vueStore.state.user.id) {
|
|
if (vueStore.state.user.id) {
|
|
//更新面包屑数据
|
|
//更新面包屑数据
|
|
- vueStore.commit('updateBreadcrumbs', { to: to.path });
|
|
|
|
|
|
+ vueStore.commit("updateBreadcrumbs", { to: to.path });
|
|
return next();
|
|
return next();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
let userControllerInstance = new userController();
|
|
let userControllerInstance = new userController();
|
|
let userInfoResult = await userControllerInstance.getUserInfoById();
|
|
let userInfoResult = await userControllerInstance.getUserInfoById();
|
|
|
|
|
|
if (userInfoResult.result != "success") {
|
|
if (userInfoResult.result != "success") {
|
|
- console.error('获取用户信息失败,原因:' + userInfoResult.reason);
|
|
|
|
|
|
+ console.error("获取用户信息失败,原因:" + userInfoResult.reason);
|
|
return next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
return next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
var _userInfo = (userInfoResult.content[0] || {}) as any;
|
|
var _userInfo = (userInfoResult.content[0] || {}) as any;
|
|
if (!_userInfo.userId) {
|
|
if (!_userInfo.userId) {
|
|
- console.error('获取用户信息失败,原因:无效的用户ID');
|
|
|
|
|
|
+ console.error("获取用户信息失败,原因:无效的用户ID");
|
|
return next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
return next({ path: logicConfig.routerNameConfig.loginRouteName });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -56,17 +54,19 @@ export class authUtils {
|
|
vueStore.commit("updateMenus", (window as any).__systemConf.menus);
|
|
vueStore.commit("updateMenus", (window as any).__systemConf.menus);
|
|
|
|
|
|
//更新面包屑数据
|
|
//更新面包屑数据
|
|
- vueStore.commit('updateBreadcrumbs', { to: to.path });
|
|
|
|
|
|
+ vueStore.commit("updateBreadcrumbs", { to: to.path });
|
|
|
|
|
|
var projects = [];
|
|
var projects = [];
|
|
- _userInfo.projects.forEach(_c => {
|
|
|
|
|
|
+ _userInfo.projects.forEach((_c) => {
|
|
projects.push({
|
|
projects.push({
|
|
id: _c.projectLocalID,
|
|
id: _c.projectLocalID,
|
|
name: _c.projectLocalName,
|
|
name: _c.projectLocalName,
|
|
- groupCode: _c.groupCode
|
|
|
|
|
|
+ groupCode: _c.groupCode,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
vueStore.commit("updateProjects", projects);
|
|
vueStore.commit("updateProjects", projects);
|
|
|
|
+ vueStore.commit("layout/setProjects", projects);
|
|
|
|
+ vueStore.commit("layout/setprojectId", projects[0].id);
|
|
vueStore.commit("updateSelectProject", projects[0]);
|
|
vueStore.commit("updateSelectProject", projects[0]);
|
|
|
|
|
|
next();
|
|
next();
|