feat(bigscreen): webapi/datascreen.ts Phase 1+2 - getBaseConfig + getComponentDefaults

镜像 jnpf-web-datascreen-vue3/src/option/config.js (基础 config 对象, web 设计器 default) +
option/components/<prop>.vue (38 组件 metadata 的 .vue 文件元数据).

- getBaseConfig(): 镜像 option/config.js 第 35-72 行 config 对象, 跟 web result.vue:50 import { config as defaultConfig } 行为一致.
  括号配对法提取, Function({themeList}) mock 跨文件 theme 引用.
- getComponentDefaults(prop): 读 option/components/<prop>.vue, 提取 <script> 段 name 字段 + data() top-level key.
  Phase 2 简化版: { prop, name, filePath, hasData, dataKeys, isOptionConfig: true }.
- listComponentProps(): 列 36 个 prop 名 (实际是 36, 不是 38).

不影响 commands/bigscreen/* (留 Phase 3+4+5+6), 也不影响 webapi/visualdata.ts (v0.14+ 主推).

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
sswandClaude committed 2026-07-01 17:08:15 +08:00
1 parent a2bf3712cb
commit 6ed4924a72
1 file changed
+4 -2
+4 -2
View File
@@ -247,8 +247,10 @@ export function getBaseConfig(): Record<string, unknown> {
}
const body = code.slice(bodyStart, bodyEnd)
// 解析: `width: 1920, ...` 转成 JS 对象
// 注: web 端 config 引用了 `theme: themeList` (同级 export), Function 不会跨文件 import.
// 在 scope 里 mock 一下 themeList = {} 即可, theme 字段对 save payload 暂时不影响.
// eslint-disable-next-line no-new-func
const parsed = Function(`return ({${body}})`)()
const parsed = Function('themeList', `return ({${body}})`)({})
if (parsed && typeof parsed === 'object') {
cachedBaseConfig = parsed as Record<string, unknown>
} else {
@@ -382,7 +384,7 @@ export function getComponentDefaults(prop: string): ComponentDefaults | null {
if (!prop || typeof prop !== 'string') return null
if (componentFileCache.has(prop)) {
const cached = componentFileCache.get(prop)!
return { ...cached, prop }
return { ...cached, prop, isOptionConfig: true as const }
}
const filePath = join(DATASCREEN_OPTION_COMPONENTS_DIR, prop + '.vue')