113 lines
3.3 KiB
TypeScript
113 lines
3.3 KiB
TypeScript
import { WidgetType, WidgetContainerProps } from './button';
|
||
|
||
// ===== 用户数据结构(复用类型,JSDoc 无法跨文件引用,放 .d.ts) =====
|
||
|
||
interface UserRoleBinding {
|
||
user_uuid: string
|
||
role_uuid: string
|
||
created_at: string
|
||
updated_at: string
|
||
created_user: string
|
||
owned_user: string
|
||
}
|
||
|
||
interface UserInfo {
|
||
uuid: string
|
||
username: string
|
||
nickname: string
|
||
email: string
|
||
last_login_ip: string
|
||
is_active: 0 | 1
|
||
UserRole: UserRoleBinding[]
|
||
[key: string]: unknown
|
||
}
|
||
|
||
|
||
interface MenuItem {
|
||
/** 菜单唯一标识 */
|
||
uuid: string
|
||
/** 菜单显示名称 */
|
||
name: string
|
||
/** 图标 class 名 */
|
||
icon: string
|
||
/** 行为目标(组件标识 / 路由 uuid 等),含义随 widgetType 而定 */
|
||
widget: string
|
||
/** 行为类型 */
|
||
widgetType: WidgetType
|
||
/** 传给目标组件的 props 映射配置 */
|
||
widgetProps: Record<string, unknown>
|
||
/** 传给目标组件的 $setting 配置 */
|
||
widgetSetting: Record<string, unknown>
|
||
/** 弹窗容器配置 */
|
||
widgetContainerSetting: WidgetContainerProps
|
||
/** 子菜单 */
|
||
children?: MenuItem[]
|
||
}
|
||
|
||
interface RouteItem {
|
||
/** 路由唯一标识 */
|
||
uuid: string
|
||
/** 路由名称 */
|
||
name: string
|
||
/** react-router path,支持动态参数(如 /page/:id) */
|
||
uri: string
|
||
/** 是否为布局路由(外层 layout,不直接渲染页面内容) */
|
||
isLayout: boolean
|
||
/** 是否需要登录才能访问 */
|
||
isLogin: boolean
|
||
/** 是否为手机端专属路由 */
|
||
isPhone: boolean
|
||
/** 路由类型 */
|
||
type: Exclude<WidgetType, 'redirect'>
|
||
/** 是否精确匹配路径 */
|
||
exact: boolean
|
||
/** widget 标识(等同于 ButtonProps.widget),经 core.getWidgetComponent 加载 */
|
||
component: string
|
||
/** 传给页面组件的 props 映射配置 */
|
||
widgetProps: Record<string, unknown>
|
||
/** 传给页面组件的 $setting 配置 */
|
||
widgetSetting: Record<string, unknown>
|
||
/** 弹窗容器配置 */
|
||
widgetContainerSetting: WidgetContainerProps
|
||
/** 附加配置(如 layout 标识等) */
|
||
extra?: Record<string, unknown>
|
||
}
|
||
|
||
// ===== http — Proxy 模式产生交叉类型,JSDoc 无法表达 =====
|
||
|
||
/** 每次请求自动附加的请求头 */
|
||
interface HttpHeaders {
|
||
/** 客户端平台标识,固定为 'web' */
|
||
Platform: string
|
||
/** SaaS 租户标识,单租户时为 null */
|
||
SaaS: string | null
|
||
/** JWT Bearer token,未登录时为 undefined */
|
||
Authorization: string | undefined
|
||
}
|
||
|
||
// ===== func — ff-worker-pipe 无类型文件,显式声明 =====
|
||
|
||
/**
|
||
* 基于 Worker 的表达式执行引擎单例;
|
||
* exec 在独立 Worker 上下文中求值一段 JS 表达式/源码
|
||
*/
|
||
interface WorkerPipeInstance {
|
||
/**
|
||
* 在 Worker 上下文中执行一段 JS 表达式
|
||
* @param expression 要执行的表达式字符串
|
||
* @param args 传给表达式的参数(可在表达式内作为第一个参数使用)
|
||
* @param fns 注入到表达式执行作用域的额外可调用函数
|
||
* @param session 会话标识;相同 session 共享 Worker 侧工作区(this)
|
||
*/
|
||
exec: (
|
||
expression: string,
|
||
args?: Record<string, unknown>,
|
||
fns?: Record<string, Function>,
|
||
session?: string
|
||
) => Promise<unknown>
|
||
/** 清除指定 session 的 Worker 侧工作区 */
|
||
clear: (session: string) => void
|
||
}
|
||
|
||
export type { HttpHeaders, MenuItem, RouteItem, UserInfo, UserRoleBinding, WorkerPipeInstance };
|