fix: when the server component path is wrong, a blank interface is still displayed (#4567)
parent
0fcc42a2fb
commit
402eaf4275
|
@ -53,13 +53,20 @@ function transformComponent(
|
||||||
component: VNode,
|
component: VNode,
|
||||||
route: RouteLocationNormalizedLoadedGeneric,
|
route: RouteLocationNormalizedLoadedGeneric,
|
||||||
) {
|
) {
|
||||||
|
// 组件视图未找到,如果有设置后备视图,则返回后备视图,如果没有,则抛出错误
|
||||||
|
if (!component) {
|
||||||
|
console.error(
|
||||||
|
'Component view not found,please check the route configuration',
|
||||||
|
);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const routeName = route.name as string;
|
const routeName = route.name as string;
|
||||||
// 如果组件没有 name,则直接返回
|
// 如果组件没有 name,则直接返回
|
||||||
if (!routeName) {
|
if (!routeName) {
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
const componentName = (component?.type as any)?.name;
|
||||||
const componentName = (component.type as any).name;
|
|
||||||
|
|
||||||
// 已经设置过 name,则直接返回
|
// 已经设置过 name,则直接返回
|
||||||
if (componentName) {
|
if (componentName) {
|
||||||
|
|
|
@ -174,12 +174,15 @@ if (enableShortcutKey.value) {
|
||||||
/>
|
/>
|
||||||
<div class="ml-2 w-full">
|
<div class="ml-2 w-full">
|
||||||
<div
|
<div
|
||||||
|
v-if="tagText || text || $slots.tagText"
|
||||||
class="text-foreground mb-1 flex items-center text-sm font-medium"
|
class="text-foreground mb-1 flex items-center text-sm font-medium"
|
||||||
>
|
>
|
||||||
{{ text }}
|
{{ text }}
|
||||||
<Badge class="ml-2 text-green-400">
|
<slot name="tagText">
|
||||||
{{ tagText }}
|
<Badge v-if="tagText" class="ml-2 text-green-400">
|
||||||
</Badge>
|
{{ tagText }}
|
||||||
|
</Badge>
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-muted-foreground text-xs font-normal">
|
<div class="text-muted-foreground text-xs font-normal">
|
||||||
{{ description }}
|
{{ description }}
|
||||||
|
@ -208,7 +211,7 @@ if (enableShortcutKey.value) {
|
||||||
{{ altView }} L
|
{{ altView }} L
|
||||||
</DropdownMenuShortcut>
|
</DropdownMenuShortcut>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator v-if="preferences.widget.lockScreen" />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
|
class="mx-1 flex cursor-pointer items-center rounded-sm py-1 leading-8"
|
||||||
@click="handleLogout"
|
@click="handleLogout"
|
||||||
|
|
Loading…
Reference in New Issue