Repository navigation
站点设置加「显示网址」开关(后端 KV + 前端读写 + 普通模式条件渲染) - #44
Merged
Merged
Conversation
后端站点设置加 show_url KV 键(缺省开),Settings API 支持 showUrl 并做布尔校验; 前端站点设置面板加已默认开启的开关,普通模式 classic/wide 卡片条件渲染网址行, 首页编辑模式恒显示。契约文档与前后端测试同步。 Checkpoint: hvm61fzKfNJWH4v1iWwdw
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.
Summary
linkStyle/searchNewTab同存现有settingsKV(键show_url,"1"/"0"),不新建表、无 schema 迁移。classic、wide两档;compact本就不显示域名);首页编辑模式不读该开关,恒显示网址,便于核对地址。Changes
后端(设置读写)
worker/src/types.ts:SiteSettingsDto增加showUrl: boolean。worker/src/services/site-data.ts:toSiteSettingsDto以(settings.show_url ?? "1") === "1"归一,缺省true,/api/public、/api/private、GET /api/admin/settings三处同时生效。worker/src/routes/admin.ts:SETTING_KEYS追加show_url;PUT /admin/settings只接受布尔值,非布尔返回 400showUrl must be a boolean,沿用「先全量校验后统一写入」的结构,被拒请求不产生半写。前端(读侧兜底与条件渲染)
web/src/lib/show-url.ts(新增):resolveShowUrl为唯一取值来源,只有显式false才关闭,缺失/脏值按开。web/src/lib/types.ts:SiteSettings增加可选showUrl?: boolean(旧后端或旧缓存缺字段时由上述函数兜底)。web/src/components/link-grid.tsx:LinkTileContent增加showUrl = true,classic/wide的域名行条件渲染;LinkGrid、CategorySection向下透传。web/src/components/public-page.tsx:解析showUrl只传给普通模式的CategorySection;HomeEditBoard调用不变。web/src/lib/mockDb.ts:mock 种子与旧 mock 库补值加showUrl: true。后台控件与契约
web/src/components/admin/settings-panels.tsx:在「搜索在新标签页打开」之下新增极简 Switch「显示网址」,沿用现有 shadcn/uiSwitch+Label,无说明文字;初值走resolveShowUrl。docs/api-contract.md:公开 DTO 示例、GET/PUT键列表补showUrl,并记录存储键、缺省值、400 口径与「编辑模式不受影响」。Testing
pnpm typecheck— web 与 worker 的tsc --noEmit均无错误。pnpm test— worker 13 个文件 214 项、web 27 个文件 318 项全部通过。新增用例覆盖:无键时 admin 与/api/public均返回true且不写库;false/true往返落"0"/"1"并镜像到公开端点;写其他设置不覆盖;非布尔 400 且保留原值/整包不写;白名单含show_url;classic/wide关闭后无域名、compact不受影响;公开页缺字段仍显示域名;编辑模式在开关关闭时仍有域名;设置面板默认开/关闭提交/缺字段三态。pnpm build— web(tsc --noEmit+ vite)与 worker 构建通过(在本分支实现时验证;本次改动不涉及构建产物)。pnpm format:check/pnpm lint— 通过,改动文件无告警。web/public/icon-index.json不受本次改动影响,未纳入 diff。