From 031d83828a20b7bc56c1723fe4eaa67fd9d8cd07 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 14 十二月 2023 00:44:12 +0800
Subject: [PATCH] update 代码规范化

---
 src/permission.ts |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/permission.ts b/src/permission.ts
index 4543d08..2fc105b 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -8,6 +8,7 @@
 import useUserStore from '@/store/modules/user';
 import useSettingsStore from '@/store/modules/settings';
 import usePermissionStore from '@/store/modules/permission';
+import { RouteRecordRaw } from 'vue-router';
 
 NProgress.configure({ showSpinner: false });
 const whiteList = ['/login', '/register', '/social-callback'];
@@ -15,11 +16,13 @@
 router.beforeEach(async (to, from, next) => {
   NProgress.start();
   if (getToken()) {
-    to.meta.title && useSettingsStore().setTitle(to.meta.title as string);
+    to.meta.title && useSettingsStore().setTitle(to.meta.title);
     /* has token*/
     if (to.path === '/login') {
       next({ path: '/' });
       NProgress.done();
+    } else if (whiteList.indexOf(to.path as string) !== -1) {
+      next();
     } else {
       if (useUserStore().roles.length === 0) {
         isRelogin.show = true;
@@ -33,7 +36,7 @@
           isRelogin.show = false;
           const accessRoutes = await usePermissionStore().generateRoutes();
           // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛�
-          accessRoutes.forEach((route) => {
+          accessRoutes.forEach((route: RouteRecordRaw) => {
             if (!isHttp(route.path)) {
               router.addRoute(route); // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
             }
@@ -46,7 +49,7 @@
     }
   } else {
     // 娌℃湁token
-    if (whiteList.indexOf(to.path) !== -1) {
+    if (whiteList.indexOf(to.path as string) !== -1) {
       // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆
       next();
     } else {

--
Gitblit v1.9.3