From 6a8891fcc536218e08b01f16024742823be5aeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=9F=E8=B1=86=E5=93=A5?= Date: Sat, 30 Jul 2022 01:24:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E8=B7=AF=E7=94=B1=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 9775e81..a9172a2 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -73,17 +73,19 @@ const addRoutes = async () => { router.addRoute(element) }) } - +let isRefresh = true router.beforeEach(async (to, from, next) => { + NProgress.start() const loginStore = useLoginStore(pinia) if (loginStore.getToken) { if (to.path === '/login') { - next('/') - } else if (to.name) { + next() + } else if (to.name && !isRefresh) { next() } else { await addRoutes() next({ ...to, replace: true }) + isRefresh = false } } else if (to.path === '/login') { next() -- Gitee