mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-23 19:32:03 +00:00
契约骨架补充:运行路径上的能力登记函数给出和今天一致的默认实现(并行开发互不卡住),build_tools 加 allow_write 参数;前端补 ViewRenderer、PrincipalPicker 的接口桩和按草稿预览的参数
This commit is contained in:
@@ -32,9 +32,12 @@ export const apps = {
|
||||
grants: (id: string) => get<{ items: AppGrant[] }>(`${at(id)}/grants`),
|
||||
setGrants: (id: string, items: AppGrant[]) => put<{ items: AppGrant[] }>(`${at(id)}/grants`, { items }),
|
||||
/** 页面解析:服务端解析好的视图模型(不可见的组件不下发,遮罩值不出服务端) */
|
||||
page: (id: string, page: string, params?: { instance?: string; params?: Record<string, unknown> }, opts?: RequestOptions) =>
|
||||
page: (id: string, page: string,
|
||||
params?: { instance?: string; params?: Record<string, unknown>; draft?: boolean }, opts?: RequestOptions) =>
|
||||
get<ViewModel>(`${at(id)}/pages/${encodeURIComponent(page)}${qs({
|
||||
instance: params?.instance, params: params?.params ? JSON.stringify(params.params) : undefined,
|
||||
// 编辑器预览:按草稿解析(不发起运行,视图取钉住版本已有的封存运行)
|
||||
draft: params?.draft ? 1 : undefined,
|
||||
})}`, opts),
|
||||
/** 发起一个实例 */
|
||||
start: (id: string, entry: string, values: Record<string, unknown>) =>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 视图渲染器:按服务端解析好的视图模型(agentlab.view/1)渲染应用页(FE-5 实现)。
|
||||
*
|
||||
* 前端只有一张「组件名 → 渲染器」的表;不认识的组件显示「此组件需要更新前端」,不报错、不空白。应用编辑器的预览
|
||||
* (FE-6)也用它:传 draft 解析出的视图模型即可。契约骨架里只有接口和最简实现,props 不变。
|
||||
*/
|
||||
import type { ViewModel, ViewNode } from '../typesApp'
|
||||
|
||||
export interface ViewRendererProps {
|
||||
model: ViewModel
|
||||
appId: string
|
||||
/** 实例页传入:组件里的待办、动作、进度按这个实例解析 */
|
||||
runId?: string
|
||||
/** 预览:不发起运行、不提交表单,点数字照样能看出处 */
|
||||
preview?: boolean
|
||||
/** 页内跳转(页签、页面链接) */
|
||||
onNavigate?: (pageId: string) => void
|
||||
/** 视图刷新、实例发起之后要重新取视图模型 */
|
||||
onReload?: () => void
|
||||
}
|
||||
|
||||
export function ViewRenderer({ model }: ViewRendererProps) {
|
||||
const walk = (nodes: ViewNode[]) => nodes.map((n) => (
|
||||
<div key={n.id} data-component={n.type}>{n.children && walk(n.children)}</div>
|
||||
))
|
||||
return <div>{walk(model.tree)}</div>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 选人或组(FE-5 实现):岗位绑定、应用授权、改派共用。关登录时只能手填名字(没有用户表)。
|
||||
* 契约骨架里只有接口和最简实现,props 不变。
|
||||
*/
|
||||
export interface Principal {
|
||||
kind: 'user' | 'group' | 'everyone'
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface PrincipalPickerProps {
|
||||
value: Principal[]
|
||||
onChange: (value: Principal[]) => void
|
||||
/** 允许选「所有人」(应用授权用) */
|
||||
allowEveryone?: boolean
|
||||
/** 只能选一个 */
|
||||
single?: boolean
|
||||
label?: string
|
||||
}
|
||||
|
||||
export function PrincipalPicker({ value }: PrincipalPickerProps) {
|
||||
return <div>{value.map((p) => p.name).join('、')}</div>
|
||||
}
|
||||
Reference in New Issue
Block a user