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

This commit is contained in:
Captain.B 2021-07-21 14:33:11 +08:00 committed by 刘瑞斌
parent ed7d5aa04b
commit 8ac52c460a
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 { export default {
path: "/api", path: "/api",
name: "api", name: "api",
redirect: "/api/home",
components: { components: {
content: () => import('@/business/components/api/ApiTest') content: () => import('@/business/components/api/ApiTest')
}, },

View File

@ -1,5 +1,5 @@
<template> <template>
<el-menu :unique-opened="true" mode="horizontal" router <el-menu :unique-opened="true" mode="horizontal"
class="header-user-menu align-right" class="header-user-menu align-right"
:background-color="color" :background-color="color"
active-text-color="#fff" active-text-color="#fff"
@ -143,6 +143,20 @@ export default {
this.currentUserInfo = response.data; 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) { changeOrg(data) {
let orgId = data.id; let orgId = data.id;
if (!orgId) { if (!orgId) {
@ -155,7 +169,7 @@ export default {
sessionStorage.setItem(WORKSPACE_ID, response.data.lastWorkspaceId); sessionStorage.setItem(WORKSPACE_ID, response.data.lastWorkspaceId);
sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId); sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId);
this.$router.push('/').then(() => { this.$router.push(this.getRedirectUrl(response.data)).then(() => {
this.reloadTopMenus(); this.reloadTopMenus();
}).catch(err => err); }).catch(err => err);
}); });
@ -170,7 +184,7 @@ export default {
sessionStorage.setItem(WORKSPACE_ID, workspaceId); sessionStorage.setItem(WORKSPACE_ID, workspaceId);
sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId); sessionStorage.setItem(PROJECT_ID, response.data.lastProjectId);
this.$router.push('/').then(() => { this.$router.push(this.getRedirectUrl(response.data)).then(() => {
this.reloadTopMenus(); this.reloadTopMenus();
}).catch(err => err); }).catch(err => err);
}); });