mirror of
http://183.237.82.114:10086/kilo/leaser_front.git
synced 2026-10-23 18:35:08 +00:00
fix: 修复构建报错
This commit is contained in:
parent
8e43e1835f
commit
79ad9275d0
1 changed files with 30 additions and 2 deletions
|
|
@ -1,7 +1,14 @@
|
|||
// src/components/menu/MenuContent.tsx
|
||||
import { defineComponent, ref, h, compile, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter, RouteRecordRaw } from 'vue-router';
|
||||
import {
|
||||
useRoute,
|
||||
useRouter,
|
||||
RouteRecordRaw,
|
||||
RouteLocationNormalized,
|
||||
RouteLocationAsPathGeneric,
|
||||
RouteLocationAsRelativeGeneric,
|
||||
} from 'vue-router';
|
||||
import type { RouteMeta } from 'vue-router';
|
||||
import { useAppStore } from '@/store';
|
||||
import { listenerRouteChange } from '@/utils/route-listener';
|
||||
|
|
@ -36,8 +43,29 @@ export default defineComponent({
|
|||
selectedKey.value = [item.name as string];
|
||||
return;
|
||||
}
|
||||
// if (item.redirect) {
|
||||
// router.push(item.redirect);
|
||||
// return;
|
||||
// }
|
||||
if (item.redirect) {
|
||||
router.push(item.redirect);
|
||||
// 1. 定义 redirect 结果的类型(匹配 router.push 接受的参数类型)
|
||||
let redirectTarget:
|
||||
| string
|
||||
| RouteLocationAsRelativeGeneric
|
||||
| RouteLocationAsPathGeneric;
|
||||
|
||||
// 2. 判断 redirect 是否为函数(动态重定向)
|
||||
if (typeof item.redirect === 'function') {
|
||||
// 执行函数:需要传入当前路由对象(route 是 useRoute() 获取的当前路由)
|
||||
// RouteLocationNormalized 是当前路由的完整类型
|
||||
redirectTarget = item.redirect(route as RouteLocationNormalized);
|
||||
} else {
|
||||
// 静态重定向:直接使用 redirect 值(字符串/对象)
|
||||
redirectTarget = item.redirect;
|
||||
}
|
||||
|
||||
// 3. 执行重定向(此时 redirectTarget 类型完全匹配 router.push 要求)
|
||||
router.push(redirectTarget);
|
||||
return;
|
||||
}
|
||||
const { hideInMenu, activeMenu } = item.meta as RouteMeta;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue