Repository navigation
feat: 主题设置——theme.json 声明,面板编辑,hub 按主题保存 - #50
Merged
Merged
Conversation
主题在 theme.json 的 config 里声明设置项(单行/多行文本、数字、开关、下拉,外加不存值的
分组标题),面板主题卡片上出现设置按钮并按声明画表单。值存在数据库的 setting 表里,按主题
short 区分,更新、重装、删除主题都不影响,备份也带着。
GET /api/themes/{short}/config 返回站长改过的项,可见范围同 /api/nodes;PUT 要管理员登录,
主题须已安装,整个对象受路由 64 KiB 请求体上限约束。面板只保存与默认值不同的项,并保留
表单不认识的 key。
This was referenced Sep 23, 2026
超过 6 项时对话框加宽、固定高度:按分组标题分节,左侧切换(手机上是横向一排),右侧两列, 多行文本占整行;有改动的节在导航上带一个点。未显示的节里的数字在保存时由面板校验,越界就 切回那一节并提示。6 项以内保持原来的单列。
- label、help、选项的 label 不是字符串时跳过该字段,否则打开设置时渲染对象抛错,整个面板白屏
- 下面没有设置项的分组标题在 configForm 里统一去掉,单列排版不再留下空标题
- GET /api/themes/{short}/config 读库失败答 500,不再答 {} 让面板在空对象上保存、冲掉已存的项
- 清空的数字框不再被当成 0
stqfdyr
added a commit
to monitor-probe/monitor-document
that referenced
this pull request
Sep 23, 2026
主题开发页新增「主题设置」:
- `theme.json` 的 `config` 字段、五种类型与 `title` 分组标题,以及设置项多少时面板的三种排版(6 项以内单列、超过 6 项两列、分成两组以上时左侧切换分组)
- `GET /api/themes/{short}/config` 的返回,以及 401、404、网络错误时一律用默认值
- 可以直接复制的读取代码(在默认主题的 tsconfig 下编译通过)和默认值、站点设置、访客偏好三层的合并顺序
- 主题自带设置界面在站长登录时 `PUT` 保存的规则与示例代码(先读 hub 里的原始对象、只存改过的项、失败要报出来),写入要求主题已安装
- 四条约定:`key` 发布后不改名、设置是公开的、设置只管显示不管权限、原始 HTML 不进页面(Markdown 须转义 HTML)
接口表改为读取五个、PUT 另见后文,架构页路由列表加上两条。对应 monitor-probe/monitor#50,hub 发版后合并。
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.
主题在
theme.json的config里声明设置项,面板按声明画表单,值由 hub 按主题保存,站长不再需要改主题包里的文件后重新打包上传。theme.json的config:string、text、number、boolean、select五种字段,外加不存值的title分组标题。Theme把它原样转给面板,旧版 hub 忽略这个字段GET /api/themes/{short}/config:返回站长改过的项,没保存过为{};可见范围同/api/nodes,任何short都能读PUT /api/themes/{short}/config:要管理员登录,主题须已安装;存在setting表的theme_config:<short>,更新、重装、删除主题都保留,数据库备份带着它测试:
cargo test新增读写、未安装主题拒绝写入、公开页关闭时匿名读取 401;npm test覆盖字段校验、默认值与覆盖项的计算;npm run build、oxlint。预览环境浏览器实测表单保存、越界数字拦截、匿名访客读取,以及 49 项、9 个分组的表单在桌面、手机宽度和深色模式下的布局。相关 #45。
文档:monitor-probe/monitor-document#16;默认主题 README:monitor-probe/monitor-theme-default#6。