优化构架
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import type { Component } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
|
||||
export type ClientRouteRelease = 'active' | 'prototype'
|
||||
|
||||
export interface ClientRouteNavigation {
|
||||
key: string
|
||||
icon: Component
|
||||
title?: string
|
||||
}
|
||||
|
||||
export interface ClientModuleNavigationGroup {
|
||||
title: string
|
||||
icon: Component
|
||||
dividerBefore?: boolean
|
||||
}
|
||||
|
||||
interface ClientRouteBase {
|
||||
path: string
|
||||
name: string
|
||||
component: Component | (() => Promise<unknown>)
|
||||
release: ClientRouteRelease
|
||||
meta: {
|
||||
title: string
|
||||
description?: string
|
||||
permission?: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface NavigableClientRoute extends ClientRouteBase {
|
||||
navigation: ClientRouteNavigation
|
||||
meta: ClientRouteBase['meta'] & { permission: string }
|
||||
}
|
||||
|
||||
export interface HiddenClientRoute extends ClientRouteBase {
|
||||
navigation?: never
|
||||
}
|
||||
|
||||
export type ClientRouteDefinition = NavigableClientRoute | HiddenClientRoute
|
||||
|
||||
export interface ClientModuleManifest {
|
||||
key: string
|
||||
navigationGroup?: ClientModuleNavigationGroup
|
||||
routes: readonly ClientRouteDefinition[]
|
||||
}
|
||||
|
||||
export function getActiveWorkspaceRoutes(modules: readonly ClientModuleManifest[]): RouteRecordRaw[] {
|
||||
return modules.flatMap((module) => module.routes
|
||||
.filter((route) => route.release === 'active')
|
||||
.map(({ release: _release, navigation: _navigation, ...route }) => route as RouteRecordRaw))
|
||||
}
|
||||
Reference in New Issue
Block a user