Skip to content

Commit

Permalink
fix(projects): 添加获取路由组件文件未找到时的错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Soybean committed Apr 21, 2022
1 parent b35ed89 commit 219f87f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/router/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;

Expand All @@ -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>;
}

Expand Down

1 comment on commit 219f87f

@vercel
Copy link

@vercel vercel bot commented on 219f87f Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.