From c87afdcf4bb6b6ee448a31f7a0f16eb3e198864e Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Fri, 23 Aug 2024 15:48:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20vue2=E4=BF=AE=E5=A4=8Drspack?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/toolkits/pro/template/tinyvue2/package.json | 1 + .../pro/template/tinyvue2/src/router/guard/menu.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/toolkits/pro/template/tinyvue2/package.json b/packages/toolkits/pro/template/tinyvue2/package.json index 3f8148ec..cb7f7ea4 100644 --- a/packages/toolkits/pro/template/tinyvue2/package.json +++ b/packages/toolkits/pro/template/tinyvue2/package.json @@ -54,6 +54,7 @@ "mockjs": "^1.1.0", "npm-run-all": "^4.1.5", "prettier": "^2.5.1", + "query-string": "^9.1.0", "style-loader": "^4.0.0", "style-resources-loader": "^1.5.0", "terser": "^5.14.2", diff --git a/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts b/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts index 598dca2b..5e416cc6 100644 --- a/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts +++ b/packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts @@ -2,7 +2,7 @@ import { useMenuStore } from '@/stores/modules/router'; import { nextTick } from 'vue'; import type { RouteRecord } from 'vue-router'; import { notFound } from '../not-found'; -// import { Router, RouteRecordRaw } from "vue-router"; +import Demo from '@/views/menu/demo/index.vue'; export interface ITreeNodeData { // node-key='id' 设置节点的唯一标识 @@ -35,7 +35,7 @@ if (BUILD_TOOLS === 'VITE' || BUILD_TOOLS === 'WEBPACK') { const components = require.context('../../views', true, reg, 'sync'); components.keys().forEach((path) => { if (path.endsWith('.vue')) { - views[`../../views/${path.replace('./', '')}`] = () => components(path); + views[`../../views/${path.replace('./', '')}`] = components(path).default; } }); } @@ -50,7 +50,7 @@ export const toRoutes = (menus: ITreeNodeData[]) => { router.push({ name: menu.label, path: menu.url, - component: () => import('@/views/menu/demo/index.vue'), + component: Demo, children: [...toRoutes(menu.children ?? [])], meta: { locale: menu.locale, @@ -61,7 +61,7 @@ export const toRoutes = (menus: ITreeNodeData[]) => { router.push({ name: menu.label, path: menu.url, - component: () => views[path](), + component: views[path], children: [...toRoutes(menu.children ?? [])], meta: { locale: menu.locale, From 14faf4d94e89db6927006a0e9e3bc521a13787e7 Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Fri, 23 Aug 2024 15:52:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20vue=E4=BF=AE=E5=A4=8Drspack=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pro/template/tinyvue/src/router/guard/menu.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts b/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts index 8ea3acf2..29685a83 100644 --- a/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts +++ b/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts @@ -1,6 +1,7 @@ import { useMenuStore } from '@/store/modules/router'; import { nextTick } from 'vue'; import { Router, RouteRecordRaw } from 'vue-router'; +import Demo from '@/views/menu/demo/index.vue'; export interface ITreeNodeData { // node-key='id' 设置节点的唯一标识 @@ -32,7 +33,7 @@ if (BUILD_TOOLS === 'VITE' || BUILD_TOOLS === 'WEBPACK') { const components = require.context('../../views', true, reg, 'sync'); components.keys().forEach((path) => { if (path.endsWith('.vue')) { - views[`../../views/${path.replace('./', '')}`] = () => components(path); + views[`../../views/${path.replace('./', '')}`] = components(path).default; } }); } @@ -45,7 +46,7 @@ const toRoutes = (menus: ITreeNodeData[]) => { router.push({ name: menu.label, path: menu.url, - component: () => import('@/views/menu/demo/index.vue'), + component: Demo, children: [...toRoutes(menu.children ?? [])], meta: { locale: menu.locale, @@ -56,7 +57,7 @@ const toRoutes = (menus: ITreeNodeData[]) => { router.push({ name: menu.label, path: menu.url, - component: () => views[path](), + component: views[path], children: [...toRoutes(menu.children ?? [])], meta: { locale: menu.locale, @@ -70,6 +71,7 @@ const toRoutes = (menus: ITreeNodeData[]) => { export const setupMenuGuard = (router: Router) => { router.beforeEach(async (to, from, next) => { + debugger; if (to.name?.toString().toLowerCase() === 'login') { next(); return; From 87b589e2df36cd31d5f715e3920f7505eb376853 Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Fri, 23 Aug 2024 15:56:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts b/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts index 29685a83..24679e8f 100644 --- a/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts +++ b/packages/toolkits/pro/template/tinyvue/src/router/guard/menu.ts @@ -71,7 +71,6 @@ const toRoutes = (menus: ITreeNodeData[]) => { export const setupMenuGuard = (router: Router) => { router.beforeEach(async (to, from, next) => { - debugger; if (to.name?.toString().toLowerCase() === 'login') { next(); return;