Repository navigation
ONE-451: 前端资源上传 UI(背景/Logo/图标)+ 预览与回填 + web 测试基建 - #12
Merged
Merged
Conversation
ONE-448 合入后 store 的 `authenticated: boolean` 已改为 `authStatus: "pending" | "authenticated" | "anonymous"`(配合探活三态)。 PR #12 新增的 public-page 测试仍按旧字段 seed,rebase 后 tsc 报错, 改为 `authStatus: "anonymous"`(语义等价:未登录)。
mapxn
force-pushed
the
agent/mary/37b6f0895f31
branch
from
October 27, 2026 08:48
727b21f to
329e773
Compare
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.
ONE-451(父单 ONE-444 Stage2 前端):在 Stage1 冻结契约(
POST /api/admin/assets、GET /assets/*、DELETE /api/admin/assets、SiteSettings.logoUrl)上做上传 UI + 预览 + 回填。不含后端改动(Stage1 后端子单 ONE-450 在独立 PR,两者文件不重叠)。改了什么
web/src/lib/types.ts:SiteSettings增logoUrl: string(对齐后端SiteSettingsDto)。web/src/lib/api.ts:新增adminUploadAsset(file, purpose)(FormData → multipart,不写 JSON Content-Type,让浏览器自带 boundary)与adminDeleteAsset(key);错误解析抽成toApiError,上传/删除的错误文案一律透出后端error原文。web/src/components/admin/asset-upload.tsx(新增):AssetUploadField(URL 输入 + 上传 + 预览 + 移除 + 上传中态)、AssetThumb(后台列表缩略)、deleteReplacedAsset(图标清旧)、useAssetDraftCleanup(取消编辑时回收未落库的新对象)。web/src/components/admin/settings-panels.tsx:站点设置里背景图与 Logo 都换成「填 URL / 上传 / 预览 / 移除」;SettingsPanel保存时带logoUrl。SearchEnginePanel补 icon 字段 + 上传 + 列表缩略。web/src/components/admin/crud-panels.tsx:CategoryPanel补分类图标(后端契约早有icon),LinkPanel的 iconUrl 旁加「上传」;链接列表用现有SiteIcon预览,分类/引擎图标用AssetThumb预览。web/src/components/public-page.tsx:settings.logoUrl有值时头部 h1 内渲染 Logo 图(alt = 站点标题),无值时维持标题文字。web/src/lib/mockDb.ts:dev mock 加uploadAsset/deleteAsset占位(返回明确标注mock-的路径,不做真实上传)。web/vitest.config.ts+web/test/(vitest + @testing-library/react + jsdom),web/package.json增test;根package.json的test改为pnpm --filter worker test && pnpm --filter web test;web/tsconfig.json把test纳入类型检查。清旧口径
PUT /settings时自动删旧 R2 对象,前端不重复删。adminDeleteAsset(旧 /assets/… 值)(外链不删)。useAssetDraftCleanup会删掉本次新上传但未落库的对象,避免孤儿。验证
pnpm lint/pnpm format:check/pnpm typecheck/pnpm build/pnpm test全绿(worker 57 + web 18 个用例)。pnpm build:web+wrangler dev的 R2 本地模拟 + 无头 Chrome 走真实 UI):登录 → 站点设置上传背景/Logo → 保存 → 首页背景与 Logo 生效 → 分类图标上传 → 列表即时预览 → 超限上传 toast 直说后端原文,10/10 通过。settings.columns为0(web 类型注释为「0 = 未配置」),但后端PUT /api/admin/settings只收 1–12,直接保存会 400。走查时按真实用户操作把列数改成合法值后保存成功。