fix: customConfig type 白名单对齐真实 GUI,修复 CI 长期红灯 - #6
Merged
Conversation
scaffold_theme.py 生成的 config.json 用了 type: "color",而 GUI 的取色器实际是 type: "input" + card: "color",validate_syntax.py 因此判其非法 —— 脚手架产物通不过 自己的校验器,CI 三个引擎自 2026-07-09 起全红。 - scaffold_theme.py / 三个 starter:primaryColor 改用 input + card: color - validate_syntax.py:白名单补齐 radio/switch/markdown/array/picture/image (逐条对照 CustomSetting.vue 的 v-if 分支核对) - validate_syntax.py:新增 card 合法值、array 缺 arrayItems、select/radio 缺 options 三项校验 - theme-config-schema.md:类型表重写并补充 arrayItems 示例 - CHANGELOG.md:记录本次修正
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
main 分支的 CI 三个引擎从 2026-07-09 起一直是红的。
根因:
scaffold_theme.py生成的config.json里主色调写的是"type": "color",而validate_syntax.py判定color非法 —— 脚手架的产物通不过自己的校验器。查证
对照 Gridea Pro 主项目的设置面板源码
frontend/src/views/theme/components/CustomSetting.vue逐条核对,发现问题比一个 typo 大:1.
color确实不是合法 type。 取色器的真实写法是"type": "input"+"card": "color"(CustomSetting.vue:40)。后端domain.ThemeConfigItem的Card字段注释也写着「卡片类型(如 color)」。校验器拦得对,是脚手架写错了。2. 但校验器的白名单本身也过时了。 注释写着「GUI 只渲染这 5 种」,实测 GUI 还支持 6 种:
radioCustomSetting.vue:93switch(与toggle等价)CustomSetting.vue:27markdownCustomSetting.vue:146array(配arrayItems)CustomSetting.vue:152picture/image(与picture-upload等价)CustomSetting.vue:116也就是说主题作者写了这些完全能用的类型,反而会被校验器拦下来,还被建议改成更差的写法。
references/theme-config-schema.md里那句「经真实 GUI 验证只有 5 种」同样是错的。3. 附加字段不会在后端被吃掉。 主题
config.json是通过domain.Theme.CustomConfig []interface{}原样透传到前端的,card/options/arrayItems都完好到达 GUI。改了什么
scripts/scaffold_theme.pyprimaryColor改用input+card: "color"—— 用户拿到真正的取色器,而不是纯文本框assets/starters/*/config.json×3scripts/validate_syntax.pyreferences/theme-config-schema.mdarrayItems完整示例CHANGELOG.md新增的三条校验:
card只允许color/post,且只对type: input生效type: array缺arrayItems→ 报错(否则面板渲染空白卡片)select/radio缺options→ 报错(否则控件根本不渲染)验证
本地按 CI 的步骤跑过:
新校验规则做了正反向测试,7 个用例行为均正确:
关联
CHANGELOG.md的同一位置插入条目,后合的那个需要解决一次 CHANGELOG 冲突(保留两段即可,无其他冲突)。🤖 Generated with Claude Code