Lesson 05 · 表单引擎
这是本项目最核心的抽象。看懂它,「加个字段」这类需求就变成十分钟的活。
课 04 已经把两条链分开了:store/modules/ 是状态,store/config/
是描述。这一课把描述那条链走到底 —— 一份
ConfigModel 到底怎么变成屏幕上的输入框、下拉、开关。
排在第 5 位是因为它的投资回报率最高。项目里 18 个配置模块共用同一套渲染机制,搞懂一次,18 个模块的需求你都会改了。而且这类需求在日常占比最大。
import.meta.glob 的装载机制
type /
summary / desc / editor /
options / meta /
condition,各管什么,证据在
src/components/PropEditor/types/config.d.ts
PropEditor/index.vue 怎么派发。它 import
了十几个控件组件,按 editor 字段决定渲染哪一个
PropEditor/Components/ 下每个组件适合什么场景:Select
/ Switch / Time / TimeWeek /
MapPoint / RelateDialog /
GroupModel / SepGroup
checkCondition()(PropEditor/helper/handler.ts)怎么让「只有类型是 X
时才显示字段 Y」生效。store/config/Npc.ts 里有大量实例
views/GameEditor/Npc/view.ts 的 Groups ——
全项目只有 NPC 模块这么做,其余模块直接把分组写死在页面里
excel_modify 的 payload 带上了它
Switch.vue 写一个,接进
PropEditor/index.vue 的派发
Item.ts 5647
行单文件、大段注释掉的死代码)
condition 联动的坑:条件字段本身被隐藏时会发生什么
src/store/config/Box.ts(最短的一份,可以整个读完),对照
/game/box 页面,逐个字段确认「这一行对应界面上哪个控件」
src/components/PropEditor/index.vue,看它 import
了哪些控件 —— 那个 import 列表就是可用控件的全集
summary