From 0c9e11ce2af429f222a82c0b8e5705e300769fbe Mon Sep 17 00:00:00 2001 From: zouzhibing Date: Fri, 30 Sep 2022 12:44:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E5=8E=BB=E6=8E=89=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/TagsView/index.vue | 3 ++- src/permission.ts | 3 +-- src/router/index.ts | 10 ---------- src/store/modules/permission.ts | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/layout/TagsView/index.vue b/src/layout/TagsView/index.vue index b128f88..7d46e3b 100644 --- a/src/layout/TagsView/index.vue +++ b/src/layout/TagsView/index.vue @@ -13,7 +13,7 @@ :key="tag.path" class="item-tag-wrap" :class="isActive(tag) ? 'active' : ''" - @click="routerGo(tag)" + @click.stop="routerGo(tag)" >
{{ tag.title }}
{ + console.log(111111111111) router.push({ path: tag.path, query: tag.query, diff --git a/src/permission.ts b/src/permission.ts index e779905..b2bc702 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -17,7 +17,7 @@ router.beforeEach(async(to, from, next) => { if(typeof(to.meta.title) === 'string'){ document.title = to.meta.title ||'vue-admin-perfect' } - const UserStore = useUserStore(); + const UserStore = useUserStore(); // 确定用户是否已登录过,存在Token const hasToken = UserStore.token if (hasToken) { @@ -46,7 +46,6 @@ router.beforeEach(async(to, from, next) => { next() } else { next(`/login?redirect=${to.path}`) - } } }) diff --git a/src/router/index.ts b/src/router/index.ts index a2556a0..60238a5 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -4,16 +4,6 @@ import Layout from "@/layout/index.vue"; interface extendRoute { hidden?:boolean } -// * 导入所有router -const metaRouters = import.meta.globEager("./modules/*.ts"); -// * 处理路由表 -export const routerArray: RouteRecordRaw[] = []; -Object.keys(metaRouters).forEach(item => { - Object.keys(metaRouters[item]).forEach((key: any) => { - routerArray.push(...metaRouters[item][key]); - }); -}); - // import tableRouter from './modules/table' import dataScreenRouter from './modules/dataScreen' diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 59d7787..5c1a1df 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -43,7 +43,7 @@ export const usePermissionStore = defineStore({ this.cacheRoutes = [] }, getCacheRoutes(){ - this.cacheRoutes = filterKeepAlive(routerArray) + this.cacheRoutes = filterKeepAlive(asyncRoutes) return this.cacheRoutes } },