普通用户建应用(前端):新建应用的三个起点(说需求、场景模板、从已有的开始);蓝图页(对话加卡片、反问选项、关节逐组进度、试运行、发布摘要按你来定 / 助手可以修 / 要找管理员分栏、逐步打勾、接着做);问数据「做成应用」改走蓝图;问数据和画布的反问收尾;页面上直接改(选中、改字、隐藏、挪动、删除、加数据卡片、自动存草稿);文件控件;我的记录列表;个人应用的界面(我的应用、刷新与剩余次数、提交审核、审核待办卡);设置页的个人应用开关;四个新检查脚本并加进完整关口

This commit is contained in:
ThearchyHelios
2026-10-15 12:09:29 +08:00
parent 277982ead3
commit a702a5c14b
49 changed files with 6953 additions and 133 deletions
+29 -2
View File
@@ -4,6 +4,9 @@
* 正式运行的表单由服务端转好放在版本详情里(VersionDetailOut.input_schema,服务端 app/apps/forms.input_schema);
* 画布试运行用的是画布上还没保存的入口字段,只能在这里按同一套规则转:没写类型的按文本,可选值变成下拉,
* 说明、默认值照搬。两处规则对不上时以服务端为准——发起时服务端照版本快照校验,这里只决定怎么画。
*
* 文件字段(normal-user-apps N9):输入节点的字段写 type: file,转成 type 为 object、x-widget 为 file 的字段,允许的类型
* 和大小(accept、max_mb)进 x-file。值是上传后拿回的引用,没上传的不传。
*/
import type { FormField, FormSchema } from '../typesApp'
@@ -14,12 +17,27 @@ export interface InputField {
description?: string
default?: unknown
example?: unknown
type?: FormField['type']
/** file:文件(上传后拿回的引用) */
type?: FormField['type'] | 'file'
enum?: (string | number)[]
format?: FormField['format']
/** 数字类型的上下限(闭区间,表单子集没有 exclusiveMinimum:「大于 0」的金额写 0.01) */
minimum?: number
maximum?: number
/** 文件字段:允许的类型(MIME 或扩展名)、大小上限(MB) */
accept?: string[]
max_mb?: number
}
/** 文件字段:type 为 object(typesApp.FormField 还没列 object 和 x-file,见报告的接口约定请求) */
function fileField(f: InputField): FormField {
const limits: { accept?: string[]; max_mb?: number } = {}
if (Array.isArray(f.accept) && f.accept.length) limits.accept = f.accept.filter((a) => typeof a === 'string' && a)
if (typeof f.max_mb === 'number' && Number.isFinite(f.max_mb) && f.max_mb > 0) limits.max_mb = f.max_mb
const field: Record<string, unknown> = { type: 'object', title: f.name, 'x-widget': 'file' }
if (f.description) field.description = f.description
if (Object.keys(limits).length) field['x-file'] = limits
return field as unknown as FormField
}
const TYPES = new Set(['string', 'number', 'integer', 'boolean', 'array'])
@@ -30,7 +48,12 @@ export function inputSchemaOf(fields: InputField[]): FormSchema {
const required: string[] = []
for (const f of fields) {
if (!f?.name) continue
const type = f.type && TYPES.has(f.type) ? f.type : 'string'
if (f.type === 'file') {
properties[f.name] = fileField(f)
if (f.required) required.push(f.name)
continue
}
const type = f.type && TYPES.has(f.type) ? f.type as FormField['type'] : 'string'
const options = Array.isArray(f.enum) && f.enum.length ? f.enum : null
const field: FormField = { type, title: f.name }
if (f.description) field.description = f.description
@@ -65,6 +88,10 @@ export function inputPayload(schema: FormSchema, values: Record<string, unknown>
const typed = values[name]
const blank = typed == null || (typeof typed === 'string' && typed.trim() === '')
if (blank && field.default == null && (field.type === 'number' || field.type === 'integer')) continue // 没填的数字不传,不传空串
if (field['x-widget'] === 'file') { // 文件:上传后拿回的引用原样传,没上传的不传
if (!blank) payload[name] = typed
continue
}
const raw = blank ? field.default ?? (field.type === 'array' ? [] : field.type === 'boolean' ? false : '') : typed
if (field.type === 'string' && !field.enum && typeof raw === 'string' && /^\s*[[{]/.test(raw)) {
try { payload[name] = JSON.parse(raw) } catch { payload[name] = raw }