refactor: 优化切换组织和工作空间之后的跳转 --bug=1003175 --user=刘瑞斌 用户切换组织/工作空间... https://www.tapd.cn/55049933/s/1026983
This commit is contained in:
parent
ed7d5aa04b
commit
8ac52c460a
|
@ -3,6 +3,7 @@ import MsProject from "@/business/components/settings/workspace/MsProject";
|
|||
export default {
|
||||
path: "/api",
|
||||
name: "api",
|
||||
redirect: "/api/home",
|
||||
components: {
|
||||
content: () => import('@/business/components/api/ApiTest')
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-menu :unique-opened="true" mode="horizontal" router
|
||||
<el-menu :unique-opened="true" mode="horizontal"
|
||||
class="header-user-menu align-right"
|
||||
:background-color="color"
|
||||
active-text-color="#fff"
|
||||
|
@ -143,6 +143,20 @@ export default {
|
|||
this.currentUserInfo = response.data;
|
||||
});
|
||||
},
|
||||
getRedirectUrl(user) {
|
||||
// console.log(user);
|
||||
if (!user.lastProjectId || !user.lastWorkspaceId) {
|
||||
// 没有项目级的权限直接回到 /
|
||||
// 只是某一个工作空间的用户组也转到 /
|
||||
return "/";
|
||||
}
|
||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||
if (redirectUrl.startsWith("/")) {
|
||||
redirectUrl = redirectUrl.substring(1);
|
||||
}
|
||||
redirectUrl = redirectUrl.split("/")[0];
|
||||
return '/' + redirectUrl + '/';
|
||||
},
|
||||
changeOrg(data) {
|
||||
let orgId = data.id;
|
||||
if (!orgId) {
|
||||
|
@ -155,7 +169,7 @@ export default {
|
|||
sessionStorage.setItem(WORKSPACE_ID, response.data.lastWorkspaceId);
|
||||
sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId);
|
||||
|
||||
this.$router.push('/').then(() => {
|
||||
this.$router.push(this.getRedirectUrl(response.data)).then(() => {
|
||||
this.reloadTopMenus();
|
||||
}).catch(err => err);
|
||||
});
|
||||
|
@ -170,7 +184,7 @@ export default {
|
|||
sessionStorage.setItem(WORKSPACE_ID, workspaceId);
|
||||
sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId);
|
||||
|
||||
this.$router.push('/').then(() => {
|
||||
this.$router.push(this.getRedirectUrl(response.data)).then(() => {
|
||||
this.reloadTopMenus();
|
||||
}).catch(err => err);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue