56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
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>)
|
|
props?: boolean | Record<string, unknown>
|
|
release: ClientRouteRelease
|
|
meta: {
|
|
title: string
|
|
description?: string
|
|
permission?: string
|
|
workspaceTab?: boolean
|
|
workspaceTitle?: string
|
|
keepAlive?: boolean
|
|
}
|
|
}
|
|
|
|
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))
|
|
}
|