fix(系统设置): 切换项目后菜单显示问题
--bug=1015848 --user=李玉号 【系统设置】一个项目有首页权限,另一个项目没有,切换项目后没有首页权限的也会显示首页 https://www.tapd.cn/55049933/s/1224349
This commit is contained in:
parent
dc82d0a0a3
commit
30e90b698e
|
@ -36,6 +36,7 @@ import {
|
|||
stopFullScreenLoading
|
||||
} from "@/common/js/utils";
|
||||
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
|
||||
import {getDefaultSecondLevelMenu} from "@/business/components/common/router/router";
|
||||
|
||||
export default {
|
||||
name: "MsHeaderWs",
|
||||
|
@ -87,17 +88,27 @@ export default {
|
|||
});
|
||||
},
|
||||
getRedirectUrl(user) {
|
||||
// todo refactor permission check
|
||||
if (!user.lastProjectId || !user.lastWorkspaceId) {
|
||||
// 没有项目级的权限直接回到 /setting/project/:type
|
||||
// 只是某一个工作空间的用户组也转到 /setting/project/:type
|
||||
return "/setting/project/:type";
|
||||
}
|
||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||
if (redirectUrl.startsWith("/")) {
|
||||
redirectUrl = redirectUrl.substring(1);
|
||||
if (!redirectUrl) {
|
||||
return '/setting';
|
||||
}
|
||||
redirectUrl = redirectUrl.split("/")[0];
|
||||
return '/' + redirectUrl + '/';
|
||||
if (redirectUrl.startsWith("/track") || redirectUrl.startsWith("/performance") || redirectUrl.startsWith("/api")) {
|
||||
// 获取有权限的跳转路径
|
||||
redirectUrl = getDefaultSecondLevelMenu(redirectUrl);
|
||||
} else {
|
||||
if (redirectUrl.startsWith("/")) {
|
||||
redirectUrl = redirectUrl.substring(1);
|
||||
}
|
||||
redirectUrl = redirectUrl.split("/")[0];
|
||||
redirectUrl = '/' + redirectUrl + '/';
|
||||
}
|
||||
return redirectUrl;
|
||||
},
|
||||
changeWs(data) {
|
||||
let workspaceId = data.id;
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
stopFullScreenLoading
|
||||
} from "@/common/js/utils";
|
||||
import {PROJECT_ID} from "@/common/js/constants";
|
||||
import {getDefaultSecondLevelMenu} from "@/business/components/common/router/router";
|
||||
|
||||
export default {
|
||||
name: "SearchList",
|
||||
|
@ -98,36 +99,44 @@ export default {
|
|||
};
|
||||
},
|
||||
reloadPage: function () {
|
||||
// todo refactor permission check
|
||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||
|
||||
let trackPermission = hasPermissions('PROJECT_TRACK_CASE:READ', 'PROJECT_TRACK_PLAN:READ', 'PROJECT_TRACK_REVIEW:READ', 'PROJECT_TRACK_ISSUE:READ', 'PROJECT_TRACK_REPORT:READ');
|
||||
let apiPermission = hasPermissions('PROJECT_API_DEFINITION:READ', 'PROJECT_API_SCENARIO:READ', 'PROJECT_API_REPORT:READ');
|
||||
let performancePermission = hasPermissions('PROJECT_PERFORMANCE_TEST:READ', 'PROJECT_PERFORMANCE_REPORT:READ');
|
||||
let copyRedirectUrl = redirectUrl;
|
||||
if (!copyRedirectUrl) {
|
||||
this.$router.push("/");
|
||||
this.reload();
|
||||
return;
|
||||
}
|
||||
if (copyRedirectUrl.startsWith("/track") || copyRedirectUrl.startsWith("/performance") || copyRedirectUrl.startsWith("/api")) {
|
||||
// 获取有权限的跳转路径
|
||||
copyRedirectUrl = getDefaultSecondLevelMenu(copyRedirectUrl);
|
||||
if (copyRedirectUrl !== '/') {
|
||||
this.$router.push(copyRedirectUrl);
|
||||
this.reloadTopMenus();
|
||||
this.reload();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 跳转至下一个有权限的菜单
|
||||
let projectPermission = hasPermissions('PROJECT_USER:READ', 'PROJECT_ENVIRONMENT:READ', 'PROJECT_OPERATING_LOG:READ', 'PROJECT_FILE:READ+JAR', 'PROJECT_FILE:READ+FILE', 'PROJECT_CUSTOM_CODE:READ');
|
||||
let uiPermission = hasPermissions('PROJECT_UI_ELEMENT:READ', 'PROJECT_UI_SCENARIO:READ', 'PROJECT_UI_REPORT:READ');
|
||||
|
||||
let redirectMap = {
|
||||
track: trackPermission,
|
||||
api: apiPermission,
|
||||
performance: performancePermission,
|
||||
project: projectPermission,
|
||||
ui: uiPermission,
|
||||
};
|
||||
let locations = redirectUrl.split('/');
|
||||
if (locations.length > 2) {
|
||||
if (!redirectMap[locations[1]]) {
|
||||
let v = true;
|
||||
for (const k in redirectMap) {
|
||||
if (redirectMap[k]) {
|
||||
this.$router.push("/" + k);
|
||||
v = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (v) {
|
||||
this.$router.push("/");
|
||||
if (locations.length > 2 && !redirectMap[locations[1]]) {
|
||||
let v = true;
|
||||
for (const k in redirectMap) {
|
||||
if (redirectMap[k]) {
|
||||
this.$router.push("/" + k);
|
||||
v = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (v) {
|
||||
this.$router.push("/");
|
||||
}
|
||||
}
|
||||
this.reloadTopMenus();
|
||||
this.reload();
|
||||
|
|
|
@ -93,7 +93,7 @@ function redirectLoginPath(originPath, next) {
|
|||
}
|
||||
}
|
||||
|
||||
function getDefaultSecondLevelMenu(toPath) {
|
||||
export function getDefaultSecondLevelMenu(toPath) {
|
||||
let {TRACK: tracks, API: apis, LOAD: loads} = SECOND_LEVEL_ROUTE_PERMISSION_MAP;
|
||||
if (tracks.map(r => r.router).indexOf(toPath) > -1) {
|
||||
return _getDefaultSecondLevelMenu(tracks, toPath);
|
||||
|
|
Loading…
Reference in New Issue