diff --git a/src/commands/bigscreen/construct.ts b/src/commands/bigscreen/construct.ts index bc00c43..e11b4e4 100644 --- a/src/commands/bigscreen/construct.ts +++ b/src/commands/bigscreen/construct.ts @@ -35,6 +35,7 @@ import { initWebapi, loadVisualData } from '../../webapi/visualdata.ts' import { getBaseConfig, listComponentProps, + getValidProps, // v0.15+ (P1-4): 镜像 web 端 dicOption.dataList 真值源 constructConfigDetail, constructComponentJson, NavEntryInput, @@ -217,7 +218,15 @@ async function runConstruct(opts: ConstructOpts): Promise { const nav = constructComponentJson(navInput) // === step 3: 校验 === - const validProps = listComponentProps() + // v0.15+ (P1-4): 优先用 getValidProps() (镜像 web 端 dicOption.dataList 30 个硬编码 + 动态) + // 兜底用 listComponentProps() (option/components/*.vue 目录扫描, 36 个但漏 code/imgList/rectangle) + let validProps: string[] + try { + validProps = getValidProps() + if (validProps.length === 0) throw new Error('empty') + } catch { + validProps = listComponentProps() + } const validation = validateConstruct({ baseConfig, nav: nav as unknown as Array>, diff --git a/src/webapi/datascreen.ts b/src/webapi/datascreen.ts index df9978a..8428e01 100644 --- a/src/webapi/datascreen.ts +++ b/src/webapi/datascreen.ts @@ -410,6 +410,45 @@ export function listComponentProps(): string[] { return listComponentFiles() } +/** + * v0.15+ (P1-4, 2026-07-02): 镜像 web 端 build.vue:1040-1042 validProp 真值源 + * + * 镜像源: jnpf-web-datascreen-vue3/src/option/config.js:268 dicOption.dataList + * - 30 hardcoded props (含 code/imgList/imgTabs/rectangle 等 components/*.vue 目录里没有的) + * - + website.componentsList.filter(ele => ele.data === true).map(ele => ele.name) + * + * 旧版 listComponentProps() 走 option/components/*.vue 目录扫描, 漏 code/imgList/imgTabs/rectangle + * → 误报 "prop=code 不在 36 个有效列表里", 但 web 设计器完全允许 + * + * 实现: 正则读 dicOption.dataList 数组字面量, 取 hardcoded 部分 (website.componentsList 需要登录态) + * + * @returns 30 个硬编码 valid props + */ +export function getValidProps(): string[] { + if (!existsSync(DATASCREEN_OPTION_CONFIG_SRC)) { + return listComponentFiles() // 兜底走旧逻辑 + } + try { + const code = readFileSync(DATASCREEN_OPTION_CONFIG_SRC, 'utf-8') + // 找 dicOption.dataList 数组字面量 + // 匹配: dataList: ['xxx', 'yyy', ...].concat(...) + const m = code.match(/dataList:\s*\[([^\]]+)\]/) + if (!m) return listComponentFiles() + // 提取 hardcoded 部分 ('xxx' 形式), 跳过后续 .concat(...) + const arr = m[1] + const props: string[] = [] + const re = /'([^']+)'/g + let mm: RegExpExecArray | null + while ((mm = re.exec(arr)) !== null) { + props.push(mm[1]) + } + // 去重 + return Array.from(new Set(props)) + } catch { + return listComponentFiles() + } +} + // ===================================================================== // Phase 3: 镜像 save 数据结构 (header.vue:200-211) → constructConfigDetail + constructComponentJson // 详见 dacli/docs/cmd-review/v0.13-webapi-form-workflow-refactor.md §8.2.4 阶段 3