From a5f37be49ab397d40ae9ae320ee292267ad85f27 Mon Sep 17 00:00:00 2001 From: zhou-sheng Date: Tue, 2 Jul 2024 11:29:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=87=8F=E5=B0=91=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 91d26d2b0..ef7780b27 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -188,15 +188,11 @@ router.beforeEach((to: ToRouteType, _from, next) => { toCorrectRoute(); } } else { - if (to.path !== "/login") { - if (whiteList.indexOf(to.path) !== -1) { - next(); - } else { - removeToken(); - next({ path: "/login" }); - } - } else { + if (to.path === "/login" || whiteList.includes(to.path)) { next(); + } else { + removeToken(); + next({ path: "/login" }); } } });