refactor: 优化切换组织和工作空间之后的跳转 --bug=1003175 --user=刘瑞斌 用户切换组织/工作空间... https://www.tapd.cn/55049933/s/1026983

This commit is contained in:
Captain.B 2021-07-21 14:23:19 +08:00 committed by 刘瑞斌
parent d061c07f02
commit 70702c14a0
2 changed files with 18 additions and 3 deletions

View File

@ -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')
},

View File

@ -1,6 +1,5 @@
<template>
<el-menu :unique-opened="true" mode="horizontal"
router
class="header-user-menu align-right"
:background-color="color"
active-text-color="#fff"
@ -148,6 +147,20 @@ export default {
}
});*/
},
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) {
@ -160,13 +173,14 @@ 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);
});
},
changeWs(data) {
let workspaceId = data.id;
if (!workspaceId) {
return false;
}
@ -177,7 +191,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);
});