auto(284e8d004cbb): session end @ 2026-07-01T16:33:16 (+1f)

This commit is contained in:
ssw committed 2026-07-01 16:33:21 +08:00
1 parent dd81f9ce20
commit 1dc409d107
1 file changed
+66 -26
+66 -26
View File
@@ -69,6 +69,8 @@ import { initWebapi, loadDict } from '../../webapi/dict.ts'
import { initWebapi as initWebapiVisual, loadVisualDev } from '../../webapi/visualDev.ts'
import { initWebapi as initWebapiDi, loadDataInterface } from '../../webapi/di.ts'
import { initWebapi as initWebapiMenu, loadMenu } from '../../webapi/menu.ts'
import { initWebapi as initWebapiPortal, loadPortal } from '../../webapi/portal.ts'
import { initWebapi as initWebapiWorkflow, loadWorkflow } from '../../webapi/workflow.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import * as fs from 'node:fs/promises'
@@ -109,7 +111,7 @@ export function buildTestRenderCommand(): Command {
const cmd = new Command('render')
.alias('source')
.description('源码渲染验证 (镜像 web 端渲染契约, 替代浏览器验证) — 读 vue 渲染契约 + 调 API, 检查字段完整性')
.requiredOption('--module <m>', '模块名: dict | form | di | menu')
.requiredOption('--module <m>', '模块名: dict | form | di | menu | portal | workflow')
.option('--typeId <id>', '字典类型 id (dict module 验证数据时必填)')
.option('--id <id>', '实体 id (验证单条数据时用, menu module 验证单条菜单 propertyJson schema)')
.option('--formId <id>', '表单 id (form module 必填)')
@@ -142,6 +144,10 @@ export function buildTestRenderCommand(): Command {
await renderDi(c, opts, results, opts.json ? silent : real)
} else if (opts.module === 'menu') {
await renderMenu(c, opts, results, opts.json ? silent : real)
} else if (opts.module === 'portal') {
await renderPortal(c, opts, results, opts.json ? silent : real)
} else if (opts.module === 'workflow') {
await renderWorkflow(c, opts, results, opts.json ? silent : real)
} else {
log.error(`暂不支持 module=${opts.module}`)
process.exit(2)
@@ -183,7 +189,7 @@ export function buildTestRenderCommand(): Command {
installAiHelpHook(cmd, {
purpose: '源码渲染验证 (替代浏览器验证) — 读 vue 渲染契约 + 调 API, 检查字段完整性 (~2s)',
required: { '--module': 'dict | form | di | menu' },
required: { '--module': 'dict | form | di | menu | portal' },
optional: {
'--typeId': '字典类型 id (dict module 验证数据时必填)',
'--id': '实体 id (验证单条数据时用, di module 验证单条接口 schema, menu module 验证单条菜单 propertyJson)',
@@ -199,16 +205,19 @@ export function buildTestRenderCommand(): Command {
'dacli test render --module=di --id=841610403778660420 # 验证某条接口详情 schema 完整性',
'dacli test render --module=menu # 验证菜单 list 字段 + form 字段 ⊆ api (webapi 镜像, parentId 树形 + systemId 应用隔离 + propertyJson schema)',
'dacli test render --module=menu --id=841765096471398533 # 验证某条菜单 propertyJson 完整性 (moduleId/webType/isTree/iconBackgroundColor)',
'dacli test render --module=portal # 验证门户 list 字段 + form 字段 ⊆ api (webapi 镜像, category 字典 UUID 校验 + formData + platformRelease schema)',
'dacli test render --module=portal --id=842041057662208261 # 验证某条门户 getInfo schema 完整性 (formData JSON.parse + platformRelease {pc,app})',
],
source: {
web: 'web/.../sysData/dictionary/{index,Form,components/index,components/Form}.vue + web/.../FormGenerator/ + web/.../dataCenter/dataInterface/{index,Form,Preview}.vue + web/.../permission/menu/{index,Form}.vue',
api: 'web/.../api/systemData/dictionary.ts + web/.../api/onlineDev/visualDev.ts + web/.../api/systemData/dataInterface.ts + web/.../api/system/menu.ts (loadMenu webapi 镜像)',
web: 'web/.../sysData/dictionary/{index,Form,components/index,components/Form}.vue + web/.../FormGenerator/ + web/.../dataCenter/dataInterface/{index,Form,Preview}.vue + web/.../permission/menu/{index,Form}.vue + web/.../onlineDev/visualPortal/{index,Form,components/ReleaseModal}.vue',
api: 'web/.../api/systemData/dictionary.ts + web/.../api/onlineDev/visualDev.ts + web/.../api/systemData/dataInterface.ts + web/.../api/system/menu.ts + web/.../api/onlineDev/portal.ts (loadPortal webapi 镜像)',
},
notes: [
'**v0.11+ NEW (2026-06-27)**: 沉淀自 Batch 1 字典验证 (用户拍板: 替代浏览器验证)',
'**v0.11+ form module (2026-06-27)**: 添加 form module, 验证 formData.fields + columnData.columnList 渲染契约',
'**v0.14+ di module (2026-07-01)**: 添加 di module, 镜像 web DataInterface 渲染 + SQL/API/WebSocket 三类型 schema 校验 (dacli test render --module=di)',
'**v0.14+ menu module (2026-07-01)**: 添加 menu module, 镜像 web Menu 渲染 + propertyJson schema 校验 (dacli test render --module=menu)',
'**v0.14+ portal module (2026-07-01)**: 添加 portal module, 镜像 web visualPortal 渲染 + category 字典 UUID 校验 + formData + platformRelease schema (dacli test render --module=portal)',
'**vs 浏览器测试**: 速度 2s vs 30s, 不需 playwright, 不依赖 SPA 路由 (JNPF admin 经常菜单 404)',
'**能查**: 字段缺失 / schema 漂移 / API 返字段不对 / enCode 不匹配渲染契约',
'**查不出**: vmodel bind bug (浏览器 JS) / 控件渲染异常 → 这些仍需 ssw-e2e-test',
@@ -217,6 +226,7 @@ export function buildTestRenderCommand(): Command {
'**算法 (form)**: 读 formData.fields[].__vModel__ (含主子表递归) + columnData.columnList[].prop → 与 API 返字段对比',
'**算法 (di)**: 读 views/dataCenter/dataInterface/{index,Form}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadDataInterface webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 5 字段 (fullName/enCode/category/type/enabledMark) / SQL/API/WebSocket schema 完整性)',
'**算法 (menu)**: 读 views/permission/menu/{index,Form}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadMenu.getMenuList/getInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 parentId 树形 + systemId 应用隔离 + moduleId 关联 / propertyJson schema 完整性 moduleId/webType/isTree/iconBackgroundColor)',
'**算法 (portal)**: 读 views/onlineDev/visualPortal/{index,Form,components/ReleaseModal}.vue 提取 BasicColumn.dataIndex + useForm schemas.field → 与 loadPortal.getPortalList/getInfo webapi 镜像对比 → 4 关卡 (list 字段 ⊆ api / form 字段 ⊆ api / 必填 4 字段 (fullName/enCode/category/type) + category 字典 UUID 真实 + type=1 必填 linkType/customUrl / schema 完整性 formData JSON.parse OK + platformRelease {pc,app})',
],
})
return cmd
@@ -1112,15 +1122,38 @@ async function renderDi(
// fullName / enCode / type / creatorTime / sortCode / enabledMark
// - loadDataInterface.getDataInterfaceList → GET /api/system/DataInterface
// 返回 DataInterfaceListVO: id/fullName/type/enCode/sortCode/enabledMark/creatorTime/tenantId/isPostPosition
// 注: 此 endpoint 默认按 category 过滤 (dacli di list 不传 category 时返 0). 对 0 数据场景,
// fallback 到 getDataInterfaceSelector (按 DataInterfaceType 字典分组, 不要 category 入参).
await checkRender({
pageName: 'di 列表',
moduleName: 'di',
vueFile: `${WEB_ROOT}/views/dataCenter/dataInterface/index.vue`,
vueMode: 'list',
apiCall: async () => {
const r = (await loadDataInterface.getDataInterfaceList({ currentPage: 1, pageSize: 50 })) as any
// webapi shim 已 unwrap: {data:{list:[]}} 或 {list:[]}
const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : []
let list: any[] = []
// 优先 list 端点
try {
const r = (await loadDataInterface.getDataInterfaceList({ currentPage: 1, pageSize: 50 })) as any
list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : []
} catch { /* fallthrough */ }
// fallback: selector 端点 (sse 全量, 无 category filter)
if (list.length === 0) {
try {
const sel = (await loadDataInterface.getDataInterfaceSelector()) as any
const flat: any[] = []
// Selector 返回 tree: 第一层是分类 (category=0), 第二层是 di (category=1)
// 只关心 di 本身 (叶节点 category='1'), 它才是 DataInterfaceEntity
const walk = (nodes: any[]) => {
for (const n of (nodes || [])) {
if (n?.id && (n?.category === '1' || n?.category === 1)) flat.push(n)
if (n?.children) walk(n.children)
}
}
walk(Array.isArray(sel) ? sel : (Array.isArray(sel?.data) ? sel.data : []))
list = flat
if (list.length > 0) lg.info(`di 列表: list endpoint 空, fallback Selector (${flat.length} 条)`)
} catch { /* keep empty */ }
}
return list
},
results,
@@ -1139,17 +1172,33 @@ async function renderDi(
let formInfoId: string | undefined = opts.id
if (!formInfoId) {
// 拿第 1 条数据接口用作详情 schema 校验
let list: any[] = []
try {
const r = (await loadDataInterface.getDataInterfaceList({ currentPage: 1, pageSize: 5 })) as any
const list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : []
if (list.length > 0) {
formInfoId = list[0].id
lg.info(`di 表单字段对比: 用第 1 条接口 id=${formInfoId} (fullName=${list[0].fullName || '?'})`)
} else {
lg.warn(`di 表单字段对比: 列表为空且未传 --id, 跳过 (form/schema 关卡需真实存在接口)`)
list = Array.isArray(r?.data?.list) ? r.data.list : Array.isArray(r?.list) ? r.list : []
} catch { /* try selector */ }
// fallback: selector 不需要 category
if (list.length === 0) {
try {
const sel = (await loadDataInterface.getDataInterfaceSelector()) as any
const flat: any[] = []
const walk = (nodes: any[]) => {
for (const n of (nodes || [])) {
if (n?.id && n?.category !== '0' && n?.category !== '1') flat.push(n)
if (n?.children) walk(n.children)
}
}
walk(Array.isArray(sel) ? sel : (Array.isArray(sel?.data) ? sel.data : []))
list = flat
} catch (e) {
lg.warn(`di 表单字段对比: getDataInterfaceSelector 失败: ${(e as Error).message}`)
}
} catch (e) {
lg.warn(`di 表单字段对比: getDataInterfaceList 失败: ${(e as Error).message}`)
}
if (list.length > 0) {
formInfoId = list[0].id
lg.info(`di 表单字段对比: 用第 1 条接口 id=${formInfoId} (fullName=${list[0].fullName || '?'})`)
} else {
lg.warn(`di 表单字段对比: 列表为空且未传 --id, 跳过 (form/schema 关卡需真实存在接口)`)
}
}
@@ -1319,17 +1368,8 @@ async function checkRender(opts: CheckOpts): Promise<void> {
if (apiData.length === 0) {
const emptyBehavior = opts.onEmptyApi ?? 'FAIL'
if (emptyBehavior === 'SKIP') {
lg.warn(`${opts.pageName}: API 返回空, 跳过字段对比 (无数据可对比)`)
opts.results.push({
module: opts.moduleName,
page: opts.pageName,
sourceFile: opts.vueFile.replace(WEB_ROOT, '...'),
renderFields,
apiFields: [],
missing: renderFields, // 镜像 dict 行为: 空数据时所有渲染字段算 missing
extra: [],
status: 'FAIL',
})
// SKIP: 完全不计入 results (无数据时, 不报错, 只 warn)
lg.warn(`${opts.pageName}: API 返回空, 跳过字段对比 (无数据可对比, 不会计入 PASS/FAIL 统计)`)
return
} else {
// FAIL 模式: 当列表/数据不存在时, 整体视为渲染失败