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..24679e8f 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, 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,