From e193dff07b7a74d978005a1f62735e8b76f88d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=8C?= <259278618@qq.com> Date: Thu, 13 Aug 2026 15:33:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=A7=E5=9C=BA=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=20theater.js=EF=BC=88=E4=BA=92=E5=8A=A8=E5=BD=A2?= =?UTF-8?q?=E6=80=81=E5=88=A4=E5=AE=9A=20+=20=E5=BC=80=E5=9C=BA=E6=BC=94?= =?UTF-8?q?=E5=87=BA=E6=95=B0=E6=8D=AE=E6=8F=90=E5=8F=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui-src/src/utils/theater.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ui-src/src/utils/theater.js diff --git a/ui-src/src/utils/theater.js b/ui-src/src/utils/theater.js new file mode 100644 index 0000000..d79529f --- /dev/null +++ b/ui-src/src/utils/theater.js @@ -0,0 +1,29 @@ +// 剧场化工具:互动形态判定 + 开场演出数据提取(决策树模型零改动) + +const INTERACTION_MAP = { 2: 'PropPick', 3: 'StepSort', 5: 'DragPlace', 7: 'FindSpot', 8: 'LinkMatch' } + +// 互动形态判定:config 互动节点 → 对应触控组件;普通决策节点 → 动作卡 +// (触控组件只有 success/fail 双出口,普通节点多分支选项语义由 ActionCard 完整保留) +export function pickInteraction(node) { + if (node && node.config && INTERACTION_MAP[node.interaction_type]) { + return INTERACTION_MAP[node.interaction_type] + } + return 'ActionCard' +} + +// 开场演出道具:入口节点选项的道具名去重,最多 4 个 +export function entryProps(entry) { + const names = [] + for (const o of (entry && entry.options) || []) { + if (o.prop && o.prop.name && !names.includes(o.prop.name)) { + names.push(o.prop.name) + if (names.length >= 4) break + } + } + return names +} + +// 开场演出角色:入口节点人物(可能为空) +export function entryCharacter(entry) { + return entry && entry.character ? entry.character : null +}