From 157008471e038e2ea359ea8caec81b734a9497a4 Mon Sep 17 00:00:00 2001 From: Soybean Date: Sat, 9 Sep 2023 02:49:32 +0800 Subject: [PATCH] fix(projects): fix old routeConst --- .vscode/settings.json | 9 +-------- examples/template-vue/package.json | 1 + examples/template-vue/src/router/elegant/routes.ts | 2 +- examples/template-vue/src/router/routes/index.ts | 2 +- packages/vue/src/context/const.ts | 4 +++- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1abea5a..4243164 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,5 @@ { - "cSpell.words": [ - "consola", - "iife", - "kolorist", - "magicast", - "tsup", - "unplugin" - ], + "cSpell.words": ["consola", "iife", "kolorist", "magicast", "tsup", "unplugin"], "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, diff --git a/examples/template-vue/package.json b/examples/template-vue/package.json index 6dd703f..208c8c9 100644 --- a/examples/template-vue/package.json +++ b/examples/template-vue/package.json @@ -2,6 +2,7 @@ "name": "template-vue", "version": "0.2.1", "private": true, + "type": "module", "scripts": { "dev": "vite", "debug": "vite --debug", diff --git a/examples/template-vue/src/router/elegant/routes.ts b/examples/template-vue/src/router/elegant/routes.ts index c99df68..4a9f03c 100644 --- a/examples/template-vue/src/router/elegant/routes.ts +++ b/examples/template-vue/src/router/elegant/routes.ts @@ -6,7 +6,7 @@ import type { ElegantRoute } from '@elegant-router/types'; export const autoRoutes: ElegantRoute[] = [ { path: '/403', - component: 'layout.blank', + component: 'layout.base', children: [ { name: '403', diff --git a/examples/template-vue/src/router/routes/index.ts b/examples/template-vue/src/router/routes/index.ts index 222a460..7472ced 100644 --- a/examples/template-vue/src/router/routes/index.ts +++ b/examples/template-vue/src/router/routes/index.ts @@ -13,7 +13,7 @@ const constantRoutes: CustomRoute[] = [ }, { path: '/:pathMatch(.*)*', - component: 'layout.default', + component: 'layout.base', children: [ { name: 'not-found', diff --git a/packages/vue/src/context/const.ts b/packages/vue/src/context/const.ts index ec17048..9b69960 100644 --- a/packages/vue/src/context/const.ts +++ b/packages/vue/src/context/const.ts @@ -28,7 +28,9 @@ async function getConstCode(trees: ElegantRouterTree[], options: ElegantVueRoute const autoRoutes = trees.map(item => transformRouteTreeToRouteRecordRaw(item, options)); - const updated = getUpdatedRouteConst(md.exports.autoRoutes as AutoRoute[], autoRoutes, options); + const oldRoutes = JSON.parse(JSON.stringify(md.exports.autoRoutes)) as AutoRoute[]; + + const updated = getUpdatedRouteConst(oldRoutes, autoRoutes, options); md.exports.autoRoutes = updated as any;