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
|
stopFullScreenLoading
|
||||||
} from "@/common/js/utils";
|
} from "@/common/js/utils";
|
||||||
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
|
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
|
||||||
|
import {getDefaultSecondLevelMenu} from "@/business/components/common/router/router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsHeaderWs",
|
name: "MsHeaderWs",
|
||||||
|
@ -87,17 +88,27 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getRedirectUrl(user) {
|
getRedirectUrl(user) {
|
||||||
|
// todo refactor permission check
|
||||||
if (!user.lastProjectId || !user.lastWorkspaceId) {
|
if (!user.lastProjectId || !user.lastWorkspaceId) {
|
||||||
// 没有项目级的权限直接回到 /setting/project/:type
|
// 没有项目级的权限直接回到 /setting/project/:type
|
||||||
// 只是某一个工作空间的用户组也转到 /setting/project/:type
|
// 只是某一个工作空间的用户组也转到 /setting/project/:type
|
||||||
return "/setting/project/:type";
|
return "/setting/project/:type";
|
||||||
}
|
}
|
||||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||||
|
if (!redirectUrl) {
|
||||||
|
return '/setting';
|
||||||
|
}
|
||||||
|
if (redirectUrl.startsWith("/track") || redirectUrl.startsWith("/performance") || redirectUrl.startsWith("/api")) {
|
||||||
|
// 获取有权限的跳转路径
|
||||||
|
redirectUrl = getDefaultSecondLevelMenu(redirectUrl);
|
||||||
|
} else {
|
||||||
if (redirectUrl.startsWith("/")) {
|
if (redirectUrl.startsWith("/")) {
|
||||||
redirectUrl = redirectUrl.substring(1);
|
redirectUrl = redirectUrl.substring(1);
|
||||||
}
|
}
|
||||||
redirectUrl = redirectUrl.split("/")[0];
|
redirectUrl = redirectUrl.split("/")[0];
|
||||||
return '/' + redirectUrl + '/';
|
redirectUrl = '/' + redirectUrl + '/';
|
||||||
|
}
|
||||||
|
return redirectUrl;
|
||||||
},
|
},
|
||||||
changeWs(data) {
|
changeWs(data) {
|
||||||
let workspaceId = data.id;
|
let workspaceId = data.id;
|
||||||
|
|
|
@ -37,6 +37,7 @@ import {
|
||||||
stopFullScreenLoading
|
stopFullScreenLoading
|
||||||
} from "@/common/js/utils";
|
} from "@/common/js/utils";
|
||||||
import {PROJECT_ID} from "@/common/js/constants";
|
import {PROJECT_ID} from "@/common/js/constants";
|
||||||
|
import {getDefaultSecondLevelMenu} from "@/business/components/common/router/router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "SearchList",
|
name: "SearchList",
|
||||||
|
@ -98,24 +99,33 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
reloadPage: function () {
|
reloadPage: function () {
|
||||||
|
// todo refactor permission check
|
||||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||||
|
let copyRedirectUrl = redirectUrl;
|
||||||
let trackPermission = hasPermissions('PROJECT_TRACK_CASE:READ', 'PROJECT_TRACK_PLAN:READ', 'PROJECT_TRACK_REVIEW:READ', 'PROJECT_TRACK_ISSUE:READ', 'PROJECT_TRACK_REPORT:READ');
|
if (!copyRedirectUrl) {
|
||||||
let apiPermission = hasPermissions('PROJECT_API_DEFINITION:READ', 'PROJECT_API_SCENARIO:READ', 'PROJECT_API_REPORT:READ');
|
this.$router.push("/");
|
||||||
let performancePermission = hasPermissions('PROJECT_PERFORMANCE_TEST:READ', 'PROJECT_PERFORMANCE_REPORT:READ');
|
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 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 uiPermission = hasPermissions('PROJECT_UI_ELEMENT:READ', 'PROJECT_UI_SCENARIO:READ', 'PROJECT_UI_REPORT:READ');
|
||||||
|
|
||||||
let redirectMap = {
|
let redirectMap = {
|
||||||
track: trackPermission,
|
|
||||||
api: apiPermission,
|
|
||||||
performance: performancePermission,
|
|
||||||
project: projectPermission,
|
project: projectPermission,
|
||||||
ui: uiPermission,
|
ui: uiPermission,
|
||||||
};
|
};
|
||||||
let locations = redirectUrl.split('/');
|
let locations = redirectUrl.split('/');
|
||||||
if (locations.length > 2) {
|
if (locations.length > 2 && !redirectMap[locations[1]]) {
|
||||||
if (!redirectMap[locations[1]]) {
|
|
||||||
let v = true;
|
let v = true;
|
||||||
for (const k in redirectMap) {
|
for (const k in redirectMap) {
|
||||||
if (redirectMap[k]) {
|
if (redirectMap[k]) {
|
||||||
|
@ -128,7 +138,6 @@ export default {
|
||||||
this.$router.push("/");
|
this.$router.push("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.reloadTopMenus();
|
this.reloadTopMenus();
|
||||||
this.reload();
|
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;
|
let {TRACK: tracks, API: apis, LOAD: loads} = SECOND_LEVEL_ROUTE_PERMISSION_MAP;
|
||||||
if (tracks.map(r => r.router).indexOf(toPath) > -1) {
|
if (tracks.map(r => r.router).indexOf(toPath) > -1) {
|
||||||
return _getDefaultSecondLevelMenu(tracks, toPath);
|
return _getDefaultSecondLevelMenu(tracks, toPath);
|
||||||
|
|
Loading…
Reference in New Issue