diff --git a/src/router/index.ts b/src/router/index.ts index 9775e8179c34eb6348dfc5b46862d584dff368da..a9172a2339e8a8dacf69431dd674e199ab244120 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()