|
@@ -1,18 +1,16 @@
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
-import type { RouteRecordRaw, RouteComponent, RouteLocationRaw } from 'vue-router'
|
|
|
|
|
|
|
+import type { RouteRecordRaw } from 'vue-router'
|
|
|
import HomeView from '@/views/Home/index.vue'
|
|
import HomeView from '@/views/Home/index.vue'
|
|
|
import EnterpriseView from '@/views/Enterprise/index.vue'
|
|
import EnterpriseView from '@/views/Enterprise/index.vue'
|
|
|
import DocView from '@/views/Doc/index.vue'
|
|
import DocView from '@/views/Doc/index.vue'
|
|
|
|
|
|
|
|
-export interface NavItem extends Partial<RouteRecordRaw> {
|
|
|
|
|
|
|
+export interface NavItem extends Omit<RouteRecordRaw, 'children'> {
|
|
|
title?: string
|
|
title?: string
|
|
|
showInNav?: boolean
|
|
showInNav?: boolean
|
|
|
- component?: RouteComponent | (() => Promise<RouteComponent>)
|
|
|
|
|
- children?: Array<NavItem & RouteRecordRaw>
|
|
|
|
|
- redirect?: RouteLocationRaw
|
|
|
|
|
|
|
+ children?: NavItem[]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const enterpriseRoutes: Array<NavItem> = [
|
|
|
|
|
|
|
+const enterpriseRoutes: NavItem[] = [
|
|
|
{
|
|
{
|
|
|
path: 'public-safety',
|
|
path: 'public-safety',
|
|
|
name: 'publicSafety',
|
|
name: 'publicSafety',
|
|
@@ -83,7 +81,7 @@ const enterpriseRoutes: Array<NavItem> = [
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-const routes: Array<NavItem> = [
|
|
|
|
|
|
|
+const routes: NavItem[] = [
|
|
|
{
|
|
{
|
|
|
path: '/',
|
|
path: '/',
|
|
|
name: 'home',
|
|
name: 'home',
|
|
@@ -114,10 +112,10 @@ const routes: Array<NavItem> = [
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
const router = createRouter({
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
|
- routes
|
|
|
|
|
|
|
+ routes: routes as RouteRecordRaw[]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
export default router
|
|
export default router
|
|
|
|
|
|
|
|
// 导出用于导航的路由
|
|
// 导出用于导航的路由
|
|
|
-export const navigation = routes.filter(route => route.showInNav)
|
|
|
|
|
|
|
+export const navigation = routes.filter((route): route is NavItem => route.showInNav === true)
|