Repository navigation
classic 砖块尺寸三档选择:大/中/小(后台设置 + 前后端联动) - #51
Merged
Merged
Conversation
Add tile_size (large/medium/small) to site settings, expose it through the public and admin settings APIs, and apply the selected size to classic tiles and home edit-mode tiles. Compact/wide layouts stay unchanged. Checkpoint: HR2tLe2rmDLQQbv-56rgj
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
tileSize(large141.5px /medium113px /small92px,缺省large),通过公共与后台 settings 接口读写,并在PUT时校验枚举。settings是键值表,新键只写一行。Changes
后端
worker/src/types.ts:新增TILE_SIZES、TileSize、isTileSize,SiteSettingsDto增加tileSize。worker/src/services/site-data.ts:toSiteSettingsDto映射tile_size,缺失/脏值统一回large。worker/src/routes/admin.ts:settings 白名单加入tile_size;PUT /api/admin/settings校验三值,非法值整包 400 且不写入同包其他键。docs/api-contract.md:补齐公开 DTO、管理端 GET/PUT 字段与默认值/校验/作用范围说明。前端
web/src/lib/tile-size.ts:三档选项、显示名与resolveTileSize读侧兜底。web/src/lib/grid-columns.ts:新增CLASSIC_TILE_SIZES与静态CLASSIC_TILE_SIZE_CLASS;classicGridMetrics(columns, tileSize)用当档砖宽计算maxWidth/columnGap,原算法结构不变。web/src/components/link-grid.tsx:linkGridLayout/linkTileClassName接受tileSize;增加CLASSIC_ICON_BOX与CLASSIC_TILE_DENSITY;LinkGrid/CategorySection透传。web/src/components/public-page.tsx:解析settings.tileSize并传给普通模式与编辑模式。web/src/components/home-edit-board.tsx:普通砖、「+」砖与DragOverlay同档。web/src/components/admin/settings-panels.tsx:classic 下新增「砖块尺寸」Select(大/中/小,带 px),compact / wide 隐藏但保存时保留值。web/src/lib/mockDb.ts:mock 默认值与旧缓存补齐tileSize。测试
worker/test/settings.test.ts覆盖默认值、三档往返、公开镜像、脏值归一、非法值原子拒绝与白名单;setup.test.ts的 settings 字段清单同步。classicGridMetrics、砖 class/图标盒/字号、公共页与编辑模式透传、后台 Select 的显示/回显/保存/隐藏。Testing
pnpm test:worker 13 套 221 条、web 29 套 356 条,全部通过。pnpm typecheck、pnpm lint(0 error,仅仓库原有 warning)、pnpm format:check、pnpm build均通过。wrangler dev+ headless Chrome 实测:1440px 下三档砖为 141.5/113/92 正方形,行组上限 1468/1240/1072,默认 8 列同行;390px 下大/中各 2 块、小 3 块,无横向溢出;编辑模式砖与「+」砖同档;长标题两行不溢出。tileSize返回 400tileSize must be 'large', 'medium' or 'small'且原值不变;/api/public正确镜像新值。/tmp/nav-tile-size/{large,medium,small}.png,按纪律未入库。pnpm build会重写web/public/icon-index.json,已还原,不在本 PR 中。