From 402eaf42751c62e2746973db7fef34dfc26ec97e Mon Sep 17 00:00:00 2001 From: Vben Date: Sat, 5 Oct 2024 11:11:30 +0800 Subject: [PATCH] fix: when the server component path is wrong, a blank interface is still displayed (#4567) --- .../effects/layouts/src/basic/content/content.vue | 11 +++++++++-- .../src/widgets/user-dropdown/user-dropdown.vue | 11 +++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/effects/layouts/src/basic/content/content.vue b/packages/effects/layouts/src/basic/content/content.vue index ffeaa666..4ce9e4db 100644 --- a/packages/effects/layouts/src/basic/content/content.vue +++ b/packages/effects/layouts/src/basic/content/content.vue @@ -53,13 +53,20 @@ function transformComponent( component: VNode, route: RouteLocationNormalizedLoadedGeneric, ) { + // 组件视图未找到,如果有设置后备视图,则返回后备视图,如果没有,则抛出错误 + if (!component) { + console.error( + 'Component view not found,please check the route configuration', + ); + return undefined; + } + const routeName = route.name as string; // 如果组件没有 name,则直接返回 if (!routeName) { return component; } - - const componentName = (component.type as any).name; + const componentName = (component?.type as any)?.name; // 已经设置过 name,则直接返回 if (componentName) { diff --git a/packages/effects/layouts/src/widgets/user-dropdown/user-dropdown.vue b/packages/effects/layouts/src/widgets/user-dropdown/user-dropdown.vue index 9a0f2d10..79695c41 100644 --- a/packages/effects/layouts/src/widgets/user-dropdown/user-dropdown.vue +++ b/packages/effects/layouts/src/widgets/user-dropdown/user-dropdown.vue @@ -174,12 +174,15 @@ if (enableShortcutKey.value) { />
{{ text }} - - {{ tagText }} - + + + {{ tagText }} + +
{{ description }} @@ -208,7 +211,7 @@ if (enableShortcutKey.value) { {{ altView }} L - +