UNPKG

vue-app-sdk

Version:
72 lines (71 loc) 2.07 kB
import { SetOptional, WithChildren } from '@rhao/types-base'; import { PageMetadata } from './interface'; type _PageMetadata = SetOptional<PageMetadata, 'id'>; /** * 定义静态页面元数据,为数据补充父子关联关系,便于统一处理接口数据与静态数据 * @param pages 页面元数据列表 * * @example * ```ts * // 推荐:使用 unplugin-macros 定义为编译宏,不会增加运行时开销 * // 注意:编译宏传入引用类型时仅支持字面量声明 * import { defineStaticPages } from 'vue-app-sdk' assert { type: 'macro' } * * // 使用宏编译 * const pages = defineStaticPages([ * { * name: 'parent-name', * path: '/parent-path', * // ... * children: [ * { * name: 'child-name', * path: 'child-path', * // ... * } * ] * } * ]) * * // 编译后 * const pages = [ * { * id: '1', * name: 'parent-name', * path: '/parent-path', * // ... * children: [ * { * id: '2', * parentId: '1', * name: 'child-name', * path: 'child-path', * // ... * } * ] * } * ] * ``` */ export declare function defineStaticPages(pages: WithChildren<_PageMetadata, 'children', false>[]): WithChildren<{ parentId?: (string | number) | undefined; path: string; name: string; routeQuery?: (string | Record<string, any>) | undefined; routeParams?: (string | Record<string, any>) | undefined; redirect?: string | undefined; file?: string | undefined; link?: (string | boolean) | undefined; activeMenu?: string | undefined; title: string | Record<string, string>; icon?: string | undefined; index?: number | undefined; roleList?: import('./interface').RoleList | undefined; isMenu?: boolean | undefined; isFull?: boolean | undefined; isAffix?: boolean | undefined; isUniq?: boolean | undefined; isKeepAlive?: boolean | undefined; id?: string | number | undefined; }, "children", false>[]; export {};