From 452b2599f4dca616a9699781783eb2480d0569e4 Mon Sep 17 00:00:00 2001 From: zuihou <244387066@qq.com> Date: Thu, 23 Sep 2021 00:05:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=8E=B7=E5=8F=96=20LAYOUT=20?= =?UTF-8?q?=E6=88=96=20IFRAME=20=E5=BF=BD=E7=95=A5=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=86=99=E3=80=82=20=E5=B9=B6=E4=B8=94=E5=9C=A8=E9=80=9A?= =?UTF-8?q?=E8=BF=87component=E6=89=BE=E4=B8=8D=E5=88=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=97=B6=E6=89=93=E5=8D=B0=E8=AD=A6=E5=91=8A=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E404=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/helper/routeHelper.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/router/helper/routeHelper.ts b/src/router/helper/routeHelper.ts index e4cdb49f..8fa9e75a 100644 --- a/src/router/helper/routeHelper.ts +++ b/src/router/helper/routeHelper.ts @@ -1,7 +1,7 @@ import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types'; import type { Router, RouteRecordNormalized } from 'vue-router'; -import { getParentLayout, LAYOUT } from '/@/router/constant'; +import { getParentLayout, LAYOUT, EXCEPTION_COMPONENT } from '/@/router/constant'; import { cloneDeep, omit } from 'lodash-es'; import { warn } from '/@/utils/log'; import { createRouter, createWebHashHistory } from 'vue-router'; @@ -27,7 +27,7 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { const { component, name } = item; const { children } = item; if (component) { - const layoutFound = LayoutMap.get(component as string); + const layoutFound = LayoutMap.get(component.toUpperCase()); if (layoutFound) { item.component = layoutFound; } else { @@ -54,12 +54,14 @@ function dynamicImport( if (matchKeys?.length === 1) { const matchKey = matchKeys[0]; return dynamicViewsModules[matchKey]; - } - if (matchKeys?.length > 1) { + } else if (matchKeys?.length > 1) { warn( 'Please do not create `.vue` and `.TSX` files with the same file name in the same hierarchical directory under the views folder. This will cause dynamic introduction failure', ); return; + } else { + warn('在src/views/下找不到`' + component + '.vue` 或 `' + component + '.TSX`, 请自行创建!'); + return EXCEPTION_COMPONENT; } }