fix(projects): 添加获取路由组件文件未找到时的错误提示

This commit is contained in:
Soybean 2022-04-21 09:04:18 +08:00
parent b35ed8960d
commit 219f87f467

View File

@ -2,6 +2,7 @@ import type { Component } from 'vue';
import { EnumLayoutComponentName } from '@/enum';
import { BasicLayout, BlankLayout } from '@/layouts';
import { views } from '@/views';
import { consoleError } from '../common';
type LayoutComponent = Record<EnumType.LayoutComponentName, () => Promise<Component>>;
@ -22,6 +23,9 @@ export function getLayoutComponent(layoutType: EnumType.LayoutComponentName) {
* @param routeKey - key
*/
export function getViewComponent(routeKey: AuthRoute.RouteKey) {
if (!views[routeKey]) {
consoleError(`该路由“${routeKey}”没有对应的组件文件!`);
}
return () => setViewComponentName(views[routeKey], routeKey) as Promise<Component>;
}