Repository navigation
nav 链接样式设置:新增 linkStyle 设置键(白名单 + DTO 带出 + 校验) - #37
Merged
Merged
Conversation
settings 白名单加 link_style,PUT 校验 classic|compact|wide(非法值 400), SiteSettingsDto 带出 linkStyle(缺省/脏值归一 classic,无 schema 迁移)。 同步 api-contract.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.
摘要
linkStyle(classic/compact/wide,缺省classic),存储沿用 settings 键值表(键link_style),无 schema 迁移。PUT /api/admin/settings接受该键并校验枚举,非法值回 400{ error };SiteSettingsDto带出linkStyle,/api/public、/api/private与后台设置接口同源输出,供前端按此渲染链接样式。改动
worker/src/types.ts:新增LINK_STYLES/LinkStyle/isLinkStyle()(仿既有VALID_VISIBILITY/isVisibility),作为枚举的唯一定义处,校验与 DTO 都复用它;SiteSettingsDto增加linkStyle。worker/src/services/site-data.ts:toSiteSettingsDto增加linkStyle,库里无此键或为脏值时一律归一classic。后台GET/PUT /api/admin/settings与/api/public、/api/private共用这一处映射,行为与wallpaperSource一致。worker/src/routes/admin.ts:SETTING_KEYS追加link_style(GET /api/admin/settings/keys自动带出);PUT /settings新增校验分支,非法值返回 400linkStyle must be 'classic', 'compact' or 'wide',且校验位于写库循环之前——被拒的请求不会部分写入同包其它设置。worker/test/settings.test.ts:新增settings linkStyle (link_style)一组共 7 个用例:缺省classic(admin + public 且不落库行)、三值往返并同步/api/public、写其它设置不清已存值、非法值(grid/Classic/wide/""/null/1/true)400 且库值不变、整包被拒不产生半截写入、库中脏值归一classic且不改写库行、白名单含link_style。worker/test/setup.test.ts:该文件对/api/public的settings做字段全集精确断言,新增 DTO 字段必须登记,补"linkStyle"一行。docs/api-contract.md:公共响应示例与「站点设置」小节同步linkStyle的枚举、存储键link_style、缺省与脏值归一规则、400 文案及"不部分写入"的约定。测试
pnpm test:worker 204/204、web 224/224(合计 428)全部通过。pnpm typecheck(web + worker)、pnpm format:check、pnpm build通过;pnpm lint退出码 0(30 条 warning 均为既有且不在本次改动文件,改动文件单独检查无告警)。workflow_dispatch在分支上跑ci.yml,Validate 的 Lint / Format check / Type check / Build / Test 全部 success,运行对应的headSha即当前提交。pnpm build会重写web/public/icon-index.json,已还原、不随本 PR 提交。