auto(284e8d004cbb): session end @ 2026-07-01T17:19:24 (+1f)
This commit is contained in:
1 parent
1093e1f707
commit
f62f2bbdd0
1 file changed
+437
@@ -3740,6 +3740,443 @@ async function renderReport(
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Bigscreen module (v0.14+ NEW, 2026-07-01 — 镜像 §TC-C 4 关卡真实契约)
|
||||
//
|
||||
// 算法 (4 关卡):
|
||||
// 1. 读 web 端 jnpf-web-datascreen-vue3/src/page/list/index.vue (addColumn/editColumn avue-form)
|
||||
// 提取列表/表单渲染字段 (title/category/password/screen/width/height/backgroundUrl/status)
|
||||
// 2. 调 loadVisualData.getList (走 webapi 镜像) → 拿全部大屏, 合并字段并集
|
||||
// 3. 4 关卡:
|
||||
// 3.1 list 字段 ⊆ api 字段 (web 端 list 用 title/fullName 渲染, 后端 list 返 title/backgroundUrl/status 等)
|
||||
// 3.2 form 字段 ⊆ api 字段 (form schemas 必能 setFieldsValue, list ∪ info)
|
||||
// 3.3 必填/外键/关联完整性: fullName+category 必填 (web 端 addColumn.rules: required)
|
||||
// 3.4 schema 完整性: config.detail JSON.parse OK + config.component JSON.parse OK + 每项含 prop/data
|
||||
// 4. --id=<id> 时追加单条大屏 schema 校验 (第 5 关卡)
|
||||
//
|
||||
// 镜像 web 端:
|
||||
// - jnpf-web-datascreen-vue3/src/page/list/index.vue L172-280 addColumn/editColumn (avue-form column prop)
|
||||
// - jnpf-web-datascreen-vue3/src/page/group/header.vue:200-211 (save formdata: visual + config.detail/component)
|
||||
// - jnpf-web-datascreen-vue3/src/api/visual.js getList/getObj/addObj/updateObj
|
||||
// - jnpf-web-datascreen-vue3/src/page/build.vue:666-689 (dataType 0-7)
|
||||
// - jnpf-web-datascreen-vue3/src/mixins/index.js:35 (configData = ['header','query','before','style'])
|
||||
// ============================================================================
|
||||
|
||||
const BIGSCREEN_WEB_ROOT = '/home/ubuntu/ccWorkDir/jnpf/前端/jnpf-web-datascreen-vue3/src'
|
||||
|
||||
/**
|
||||
* 从 jnpf-web-datascreen-vue3/src/page/list/index.vue 提取 addColumn + editColumn 的 prop 字段
|
||||
* 镜像 web list/index.vue L172-280
|
||||
*/
|
||||
async function extractBigscreenFormRenderFields(): Promise<string[]> {
|
||||
const vueFile = `${BIGSCREEN_WEB_ROOT}/page/list/index.vue`
|
||||
const src = await fs.readFile(vueFile, 'utf-8')
|
||||
const fields: string[] = []
|
||||
// addColumn: L172-233
|
||||
// editColumn: L234-280
|
||||
// 用 prop: 'xxx' 模式提取 (注意: prop: 'width' 单引号, prop: "width" 双引号 都匹配)
|
||||
const re = /prop:\s*['"]([^'"]+)['"]/g
|
||||
let m: RegExpExecArray | null
|
||||
while ((m = re.exec(src)) !== null) {
|
||||
if (!fields.includes(m[1])) fields.push(m[1])
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 bigscreen module: 4 关卡 + 可选第 5 关卡 (单条 schema 完整性)
|
||||
*/
|
||||
async function renderBigscreen(
|
||||
c: JnpfClient,
|
||||
opts: RenderOpts,
|
||||
results: RenderCheckResult[],
|
||||
logFn: { info: (...a: unknown[]) => void; warn: (...a: unknown[]) => void; error: (...a: unknown[]) => void } = real,
|
||||
): Promise<void> {
|
||||
await initWebapiVisualData(c)
|
||||
const lg = logFn
|
||||
|
||||
// === 1. 读 web 端渲染契约 ===
|
||||
// jnpf-web-datascreen-vue3 webapp 列表页用 avue-form (不是 el-table) 渲染大屏缩略图卡片
|
||||
// 渲染字段从 addColumn + editColumn 提取 (共 8 字段):
|
||||
// category / title / password / screen / width / height / backgroundUrl / status
|
||||
let formFields: string[] = []
|
||||
try {
|
||||
formFields = await extractBigscreenFormRenderFields()
|
||||
} catch (e) {
|
||||
lg.error(`读 bigscreen list/index.vue 失败: ${(e as Error).message}`)
|
||||
}
|
||||
if (formFields.length === 0) {
|
||||
lg.warn('bigscreen 渲染字段为空 (未提取到 addColumn/editColumn, 检查 list/index.vue 结构)')
|
||||
}
|
||||
// list 渲染字段: web 端 list 用 {{ item.title }} + 状态, 等同 form 的 title + status 子集
|
||||
const listFields = ['title', 'status', 'backgroundUrl']
|
||||
|
||||
// === 2. 调 webapi 拿实际数据 ===
|
||||
// 注: web 端 list 端点要求传 category (web list/index.vue:466-468),
|
||||
// 否则后端返 0 条. 默认用 category='1' (数据大屏) 尝试, 跟现有 construct/create 命令一致
|
||||
let apiFlat: any[] = []
|
||||
let apiSource: 'live-data' | 'empty' = 'empty'
|
||||
let triedCategories: string[] = []
|
||||
for (const cat of ['1', '2', '']) {
|
||||
triedCategories.push(cat || '<空>')
|
||||
try {
|
||||
const r: any = await loadVisualData.getList({ current: 1, size: 50, title: '', category: cat })
|
||||
// 兼容 {data: {records: [...]}} 和 {records: [...]} 多种返回
|
||||
const records = Array.isArray(r?.data?.records) ? r.data.records
|
||||
: Array.isArray(r?.records) ? r.records
|
||||
: Array.isArray(r?.data?.list) ? r.data.list
|
||||
: Array.isArray(r?.list) ? r.list
|
||||
: Array.isArray(r?.data) ? r.data
|
||||
: []
|
||||
if (records.length > 0) {
|
||||
apiFlat = records
|
||||
apiSource = 'live-data'
|
||||
if (cat !== '') lg.info(`bigscreen list: 用 category="${cat}" 拿到 ${apiFlat.length} 条`)
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
lg.warn(`loadVisualData.getList category="${cat}" 失败: ${(e as Error).message}`)
|
||||
}
|
||||
}
|
||||
if (apiSource === 'empty' && triedCategories.length > 0) {
|
||||
lg.warn(`bigscreen list: 尝试 category=${triedCategories.join(',')} 都返回空, 字段对比会标记全部缺失 (无大屏数据, 可通过 dacli bigscreen create 或 construct 创建测试大屏)`)
|
||||
}
|
||||
|
||||
if (apiSource === 'empty') {
|
||||
lg.warn('bigscreen API 返回空, 字段对比会标记全部缺失 (无大屏数据, 可通过 dacli bigscreen create 或 construct 创建测试大屏)')
|
||||
}
|
||||
|
||||
// 收集 API 字段 (所有样本的字段并集)
|
||||
const apiFieldSet = new Set<string>()
|
||||
for (const item of apiFlat) {
|
||||
if (item && typeof item === 'object') {
|
||||
for (const k of Object.keys(item)) apiFieldSet.add(k)
|
||||
}
|
||||
}
|
||||
const apiFields = Array.from(apiFieldSet).sort()
|
||||
|
||||
// === 3.1 Gate 1: 列表字段 ⊆ api 字段 ===
|
||||
// web 端 list/index.vue L76-82: {{ item.title }} + item.status (发布/未发布) + item.backgroundUrl (缩略图)
|
||||
// 后端 list 实际返 title / fullName / enCode / category / status / backgroundUrl
|
||||
// 注意: list 期望的 title 字段 + 实际 list 返 title (web 端字段名一致) + form 期望的 status (发布状态)
|
||||
{
|
||||
const renderSet = new Set(listFields)
|
||||
// title 兼容: web 端绑 item.title, 后端 list 实际可能返 title 或 fullName. 这里把 fullName 也算 API 字段
|
||||
const titleAliases = new Set([...apiFieldSet])
|
||||
if (titleAliases.has('fullName')) titleAliases.add('title')
|
||||
const missing = listFields.filter(f => !titleAliases.has(f))
|
||||
const extra = apiFields.filter(f => !renderSet.has(f))
|
||||
const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL'
|
||||
results.push({
|
||||
module: 'bigscreen',
|
||||
page: '大屏列表 (list 卡片)',
|
||||
sourceFile: 'jnpf-web-datascreen-vue3/src/page/list/index.vue L75-83 ({{ item.title }}+item.status+item.backgroundUrl)',
|
||||
renderFields: listFields,
|
||||
apiFields,
|
||||
missing,
|
||||
extra,
|
||||
status,
|
||||
})
|
||||
const icon = status === 'PASS' ? '✓' : '✗'
|
||||
lg.info(`${icon} 大屏列表: ${status} (${listFields.length} 渲染字段, ${apiFields.length} API 字段 [源:${apiSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`)
|
||||
}
|
||||
|
||||
// === 3.2 Gate 2: 表单字段 ⊆ api 字段 (list ∪ getInfo) ===
|
||||
// 镜像 web list/index.vue L172-280 addColumn/editColumn: category/title/password/screen/width/height/backgroundUrl/status
|
||||
// web 端 form 用 avue-form setFieldsValue, form 必填字段应 ⊆ (list API 字段 ∪ info API 字段)
|
||||
// getInfo 返 { visual: {...}, config: { detail: <JSON string>, component: <JSON string>, ... } }
|
||||
// - visual 字段直接可访问
|
||||
// - config.detail 是 JSON 字符串, 解析后含 width/height/screen 等 (来自 baseConfig)
|
||||
let infoUnionSet = new Set<string>()
|
||||
let infoSource = 'list-only'
|
||||
if (apiFlat.length > 0) {
|
||||
const sample = apiFlat.find(b => b.id) || apiFlat[0]
|
||||
try {
|
||||
const infoResp: any = await loadVisualData.getObj(sample.id)
|
||||
// shim unwrap, r.data = { visual: {...}, config: {...} }
|
||||
const data = (infoResp as any)?.data || infoResp
|
||||
if (data && typeof data === 'object') {
|
||||
infoSource = 'list+info'
|
||||
// visual 字段 (title/password/category/backgroundUrl/id/status)
|
||||
const visual = (data.visual && typeof data.visual === 'object') ? data.visual : data
|
||||
for (const k of Object.keys(visual)) infoUnionSet.add(k)
|
||||
if (data.config && typeof data.config === 'object') {
|
||||
for (const k of Object.keys(data.config)) infoUnionSet.add(`config.${k}`)
|
||||
// config.detail 是 JSON 字符串, 解析后含 width/height/screen/name/backgroundImage
|
||||
if (typeof data.config.detail === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(data.config.detail)
|
||||
if (parsed && typeof parsed === 'object') {
|
||||
for (const k of Object.keys(parsed)) infoUnionSet.add(`config.detail.${k}`)
|
||||
// 简化别名: 把 config.detail.* 字段平铺一份 (form 直接要 width/height/screen)
|
||||
for (const k of Object.keys(parsed)) infoUnionSet.add(k)
|
||||
}
|
||||
} catch { /* ignore parse error, will be caught in Gate 4 */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
lg.warn(`getInfo(${sample.id}) 失败 (Gate 2 仅用 list): ${(e as Error).message}`)
|
||||
}
|
||||
}
|
||||
const formApiFieldSet = new Set<string>([...apiFieldSet, ...infoUnionSet])
|
||||
const formApiFields = Array.from(formApiFieldSet).sort()
|
||||
// 处理 alias: form 期望 title 字段, list 实际可能返 fullName, info 必返 title (visual.title)
|
||||
const resolveField = (f: string) => formApiFieldSet.has(f) ||
|
||||
(f === 'title' && (formApiFieldSet.has('fullName') || formApiFieldSet.has('visual.title')))
|
||||
{
|
||||
const renderSet = new Set(formFields)
|
||||
const missing = formFields.filter(f => !resolveField(f))
|
||||
const extra = formApiFields.filter(f => !renderSet.has(f))
|
||||
const status: 'PASS' | 'FAIL' = missing.length === 0 ? 'PASS' : 'FAIL'
|
||||
results.push({
|
||||
module: 'bigscreen',
|
||||
page: '大屏表单 (addColumn/editColumn)',
|
||||
sourceFile: 'jnpf-web-datascreen-vue3/src/page/list/index.vue L172-280 (addColumn+editColumn avue-form)',
|
||||
renderFields: formFields,
|
||||
apiFields: formApiFields,
|
||||
missing,
|
||||
extra,
|
||||
status,
|
||||
})
|
||||
const icon = status === 'PASS' ? '✓' : '✗'
|
||||
lg.info(`${icon} 大屏表单: ${status} (${formFields.length} 渲染字段, ${formApiFields.length} API 字段 [源:${infoSource}]${missing.length ? `, 缺 ${missing.length}` : ''})`)
|
||||
}
|
||||
|
||||
// === 3.3 Gate 3: 必填/外键/关联完整性 ===
|
||||
// 镜像 web list/index.vue L182-186 (addColumn.category rules: required)
|
||||
// L191-195 (addColumn.title rules: required)
|
||||
// L211-216 (addColumn.width rules: required, display=false)
|
||||
// L223-228 (addColumn.height rules: required, display=false)
|
||||
// 4 必填: title (fullName) + category + width + height
|
||||
const requiredIssues: string[] = []
|
||||
const displayFalseWidthHeight = { width: 0, height: 0 }
|
||||
if (apiFlat.length > 0) {
|
||||
for (const b of apiFlat) {
|
||||
const label = b.title || b.fullName || b.enCode || b.id || '<无标识>'
|
||||
if (!b.title && !b.fullName) requiredIssues.push(`${label}: title/fullName 缺失 (web addColumn L191-195 必填)`)
|
||||
if (!b.category) requiredIssues.push(`${label}: category 缺失 (web addColumn L182-186 必填)`)
|
||||
// width/height 来自 baseConfig (web 端 user 必填, 后端 list 不一定返)
|
||||
if (b.width !== undefined && b.width !== null && b.width !== '') displayFalseWidthHeight.width++
|
||||
if (b.height !== undefined && b.height !== null && b.height !== '') displayFalseWidthHeight.height++
|
||||
}
|
||||
} else {
|
||||
requiredIssues.push('无大屏数据 (跳过必填校验)')
|
||||
}
|
||||
{
|
||||
const status: 'PASS' | 'FAIL' = requiredIssues.length === 0 ? 'PASS' : 'FAIL'
|
||||
results.push({
|
||||
module: 'bigscreen',
|
||||
page: '必填/外键/关联完整性',
|
||||
sourceFile: 'addColumn L182-228 (category+title+width+height rules: required)',
|
||||
renderFields: ['title', 'category', 'width', 'height'],
|
||||
apiFields: ['title', 'category', 'width', 'height'],
|
||||
missing: requiredIssues,
|
||||
extra: [],
|
||||
status,
|
||||
})
|
||||
if (requiredIssues.length === 0) {
|
||||
lg.info(`✓ 必填/外键/关联完整性: PASS (${apiFlat.length} 大屏, width 字段 ${displayFalseWidthHeight.width} 条, height 字段 ${displayFalseWidthHeight.height} 条)`)
|
||||
} else {
|
||||
lg.error(`✗ 必填/外键/关联完整性: FAIL (${requiredIssues.slice(0, 3).join(' | ')}${requiredIssues.length > 3 ? '...' : ''})`)
|
||||
}
|
||||
}
|
||||
|
||||
// === 3.4 Gate 4: schema 完整性 (config.detail JSON.parse + config.component JSON.parse) ===
|
||||
// 镜像 web group/header.vue:200-211 (save formdata: config.detail + config.component 都是 JSON 字符串)
|
||||
// 镜像 web page/build.vue:666-692 (dataType 0-7 + isFolder = children)
|
||||
// 镜像 web mixins/index.js:35 (configData = ['header','query','before','style'])
|
||||
// 校验:
|
||||
// 1. config.detail 必能 JSON.parse OK (空 detail 用 "{}" 占位, 必须可解析)
|
||||
// 2. config.component 必能 JSON.parse OK (空 component 用 "[]" 占位)
|
||||
// 3. component 数组每项含 index/name/display/lock/group/option/component.prop/data 字段
|
||||
// 4. configData 4 字段必须在 detail 解析后存在
|
||||
const schemaIssues: string[] = []
|
||||
let detailParsedCount = 0
|
||||
let componentParsedCount = 0
|
||||
const configDataFields = ['header', 'query', 'before', 'style']
|
||||
let checkCount = 0
|
||||
for (const b of apiFlat) {
|
||||
// shim 返回 list 端点不返 config, 只有 getInfo 返. 跳过 list 端点无 config 的大屏
|
||||
// 这里仅对有 config 字段的样本做 schema 校验
|
||||
const configRaw = b.config
|
||||
if (configRaw === undefined) continue
|
||||
checkCount++
|
||||
const label = b.title || b.fullName || b.id || '<无标识>'
|
||||
|
||||
// detail
|
||||
if (typeof configRaw.detail !== 'string') {
|
||||
schemaIssues.push(`${label}: config.detail 类型不对 (期望 string JSON, 实际 ${typeof configRaw.detail})`)
|
||||
} else {
|
||||
try {
|
||||
const parsed = JSON.parse(configRaw.detail)
|
||||
if (typeof parsed !== 'object' || parsed === null) {
|
||||
schemaIssues.push(`${label}: config.detail 解析后非对象`)
|
||||
} else {
|
||||
detailParsedCount++
|
||||
// configData 4 字段必含
|
||||
for (const cf of configDataFields) {
|
||||
if (parsed[cf] === undefined) {
|
||||
schemaIssues.push(`${label}: config.detail 缺 configData 字段 "${cf}" (web mixins/index.js:35)`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
schemaIssues.push(`${label}: config.detail JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`)
|
||||
}
|
||||
}
|
||||
|
||||
// component
|
||||
if (typeof configRaw.component !== 'string') {
|
||||
schemaIssues.push(`${label}: config.component 类型不对 (期望 string JSON, 实际 ${typeof configRaw.component})`)
|
||||
} else {
|
||||
try {
|
||||
const parsed = JSON.parse(configRaw.component)
|
||||
if (!Array.isArray(parsed)) {
|
||||
schemaIssues.push(`${label}: config.component 解析后非数组`)
|
||||
} else {
|
||||
componentParsedCount++
|
||||
// 每项必含 prop/data 字段
|
||||
for (let i = 0; i < parsed.length; i++) {
|
||||
const c = parsed[i]
|
||||
if (!c || typeof c !== 'object') {
|
||||
schemaIssues.push(`${label}: config.component[${i}] 非对象`)
|
||||
continue
|
||||
}
|
||||
// prop 可能在 component.prop (web 端) 或 name (兜底)
|
||||
const compObj = c.component || {}
|
||||
const prop = compObj.prop || c.name
|
||||
if (!prop) schemaIssues.push(`${label}: config.component[${i}] 缺 prop (web build.vue:705-709 validProp 必填)`)
|
||||
if (!c.data || typeof c.data !== 'object') {
|
||||
schemaIssues.push(`${label}: config.component[${i}] (prop=${prop}) 缺 data 字段 (web build.vue:666-689 dataType)`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
schemaIssues.push(`${label}: config.component JSON.parse 失败: ${(e as Error).message.slice(0, 60)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
const status: 'PASS' | 'FAIL' = schemaIssues.length === 0 ? 'PASS' : 'FAIL'
|
||||
results.push({
|
||||
module: 'bigscreen',
|
||||
page: 'config schema 完整性',
|
||||
sourceFile: 'group/header.vue:200-211 (save formdata) + build.vue:666-692 (dataType) + mixins/index.js:35 (configData)',
|
||||
renderFields: ['config.detail', 'config.component', 'configData.header', 'configData.query', 'configData.before', 'configData.style', 'component[].prop', 'component[].data'],
|
||||
apiFields: checkCount > 0 ? apiFlat.filter(b => b.config).map(b => b.title || b.id).slice(0, 5) : [],
|
||||
missing: schemaIssues,
|
||||
extra: [],
|
||||
status,
|
||||
})
|
||||
if (schemaIssues.length === 0) {
|
||||
lg.info(`✓ config schema: PASS (${checkCount} 大屏 schema 校验, detail 解析 ${detailParsedCount}, component 解析 ${componentParsedCount})`)
|
||||
} else {
|
||||
lg.error(`✗ config schema: FAIL (${schemaIssues.slice(0, 3).join(' | ')}${schemaIssues.length > 3 ? '...' : ''})`)
|
||||
}
|
||||
}
|
||||
|
||||
// === 3.5 Gate 5 (可选, --id): 单条大屏 getInfo 完整性 + schema 详细校验 ===
|
||||
if (opts.id) {
|
||||
let infoDetail: any
|
||||
try {
|
||||
infoDetail = await loadVisualData.getObj(opts.id)
|
||||
} catch (e) {
|
||||
lg.error(`getInfo(${opts.id}) 失败: ${(e as Error).message}`)
|
||||
infoDetail = null
|
||||
}
|
||||
const data = (infoDetail as any)?.data || infoDetail
|
||||
if (!data || typeof data !== 'object') {
|
||||
lg.error(`getInfo(${opts.id}) 返回非对象: ${JSON.stringify(infoDetail).slice(0, 200)}`)
|
||||
} else {
|
||||
const visual = (data.visual && typeof data.visual === 'object') ? data.visual : data
|
||||
const config = (data.config && typeof data.config === 'object') ? data.config : null
|
||||
const visualFieldSet = new Set(Object.keys(visual))
|
||||
const visualFields = Array.from(visualFieldSet).sort()
|
||||
// form 必填字段 (来自 addColumn + editColumn)
|
||||
// 注: width/height/screen 在 visual 上不一定有, 来自 config.detail (baseConfig) 解析
|
||||
// status 在 visual 上也不一定有 (后端返 bool 或 数字)
|
||||
// 这里检查 visual ∪ config.detail.parsed 的并集
|
||||
const requiredInfoFields = [
|
||||
'title', 'category', 'password', 'screen',
|
||||
'width', 'height', 'backgroundUrl', 'status',
|
||||
]
|
||||
// 合并 visual + config.detail 解析后的字段集 + list 端点返的字段 (status 来自 list)
|
||||
const fullFieldSet = new Set(visualFieldSet)
|
||||
// 拿 list 端点对应 id 的样本, 补 status 等 list-only 字段
|
||||
const listSample = apiFlat.find(b => String(b.id) === String(opts.id))
|
||||
if (listSample) {
|
||||
for (const k of Object.keys(listSample)) fullFieldSet.add(k)
|
||||
}
|
||||
let configDetailParsed: Record<string, unknown> | null = null
|
||||
if (config && typeof config.detail === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(config.detail)
|
||||
if (parsed && typeof parsed === 'object') {
|
||||
configDetailParsed = parsed
|
||||
for (const k of Object.keys(parsed)) fullFieldSet.add(k)
|
||||
}
|
||||
} catch { /* */ }
|
||||
}
|
||||
const missing = requiredInfoFields.filter(f => !fullFieldSet.has(f))
|
||||
// 处理 alias: title <-> fullName
|
||||
if (!fullFieldSet.has('title') && fullFieldSet.has('fullName')) {
|
||||
const idx = missing.indexOf('title')
|
||||
if (idx >= 0) missing.splice(idx, 1)
|
||||
}
|
||||
// config 解析
|
||||
let configOk = false
|
||||
let configDetails = ''
|
||||
if (config) {
|
||||
let detailOk = false
|
||||
let componentOk = false
|
||||
if (typeof config.detail === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(config.detail)
|
||||
if (typeof parsed === 'object' && parsed !== null) detailOk = true
|
||||
} catch { /* */ }
|
||||
}
|
||||
if (typeof config.component === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(config.component)
|
||||
if (Array.isArray(parsed)) componentOk = parsed.length
|
||||
// 详细: 数组每项 prop/data
|
||||
if (Array.isArray(parsed)) {
|
||||
for (let i = 0; i < parsed.length; i++) {
|
||||
const c = parsed[i]
|
||||
const compObj = c?.component || {}
|
||||
const prop = compObj.prop || c?.name || '?'
|
||||
if (!compObj.prop) missing.push(`config.component[${i}].prop`)
|
||||
if (!c?.data) missing.push(`config.component[${i}].data`)
|
||||
}
|
||||
}
|
||||
} catch { /* */ }
|
||||
}
|
||||
configOk = detailOk && componentOk !== false
|
||||
configDetails = `detail=${detailOk ? 'OK' : 'FAIL'} component=${componentOk === false ? 'FAIL' : `${componentOk} 项`}`
|
||||
} else {
|
||||
missing.push('config 段缺失 (getInfo 应返 {visual, config})')
|
||||
}
|
||||
const status: 'PASS' | 'FAIL' = missing.length === 0 && configOk ? 'PASS' : 'FAIL'
|
||||
results.push({
|
||||
module: 'bigscreen',
|
||||
page: '单条大屏 getInfo 完整性',
|
||||
sourceFile: `getInfo (id=${opts.id}, config: ${configDetails})`,
|
||||
renderFields: requiredInfoFields.concat(['config.detail', 'config.component', 'config.component[].prop', 'config.component[].data']),
|
||||
apiFields: visualFields,
|
||||
missing,
|
||||
extra: [],
|
||||
status,
|
||||
})
|
||||
if (status === 'PASS') {
|
||||
lg.info(`✓ 单条大屏 getInfo: PASS (${visualFields.length} visual 字段, ${configDetails})`)
|
||||
} else {
|
||||
lg.error(`✗ 单条大屏 getInfo: FAIL (${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? '...' : ''})`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 日志门面 (json 模式静默, 否则用 log)
|
||||
const real = {
|
||||
info: log.info,
|
||||
|
||||
Reference in new issue
Block a user