diff --git a/frontend/src/business/components/common/router/router.js b/frontend/src/business/components/common/router/router.js index 1caa5f8907..312338f335 100644 --- a/frontend/src/business/components/common/router/router.js +++ b/frontend/src/business/components/common/router/router.js @@ -1,12 +1,13 @@ import Vue from "vue"; -import VueRouter from 'vue-router' +import VueRouter from 'vue-router'; import RouterSidebar from "./RouterSidebar"; import Setting from "@/business/components/settings/router"; import API from "@/business/components/api/router"; import Performance from "@/business/components/performance/router"; import Track from "@/business/components/track/router"; +import {getCurrentUserId} from "@/common/js/utils"; -const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/) +const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/); const Report = requireContext.keys().map(key => requireContext(key).report); const ReportObj = Report && Report != null && Report.length > 0 && Report[0] != undefined ? Report : [{path: "/sidebar"}]; @@ -48,8 +49,8 @@ router.beforeEach((to, from, next) => { //重复点击导航路由报错 const routerPush = VueRouter.prototype.push; VueRouter.prototype.push = function push(location) { - return routerPush.call(this, location).catch(error => error) -} + return routerPush.call(this, location).catch(error => error); +}; // 登入后跳转至原路径 @@ -57,6 +58,11 @@ function redirectLoginPath(originPath) { let redirectUrl = sessionStorage.getItem('redirectUrl'); let loginSuccess = sessionStorage.getItem('loginSuccess'); sessionStorage.setItem('redirectUrl', originPath); + // 换一个用户登录同一个浏览器,跳转到 / + if (getCurrentUserId() !== sessionStorage.getItem('lastUser')) { + sessionStorage.setItem('lastUser', getCurrentUserId()); + redirectUrl = '/'; + } if (redirectUrl && loginSuccess) { sessionStorage.removeItem('loginSuccess'); router.push(redirectUrl); @@ -65,4 +71,4 @@ function redirectLoginPath(originPath) { } -export default router +export default router;