From 929ca1e0a1e8e9f297d188d0f918e2fc62ffbcd6 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 28 May 2021 18:02:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=B3=BB=E7=BB=9F=E8=B7=B3=E8=BD=AC=E8=87=B3?= =?UTF-8?q?/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/common/router/router.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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;