Repository navigation
ONE-185 nav v1: 前端迁入仓库 web/ 并对接冻结契约(should-fix 落地) - #5
Merged
Merged
Conversation
- Move nav-app SPA into web/ (src, public, design-system, shadcn ui) and
wire it into the monorepo pnpm workspace (web package deps, tsconfig,
vite config with @ alias + tailwindcss).
- Should-fix 1: load mockDb only in dev via dynamic import behind
import.meta.env.DEV; production build no longer bundles placeholder
data (incl. example private domains).
- Should-fix 2: GET /api/private returns full site data (same shape as
/api/public); public page uses privateData.categories as the full list
after login (no public+private concat), private zones derived from
public/private endpoint semantics.
- Should-fix 3: align endpoints/naming to docs/api-contract.md — /api/auth/*
(login/2fa/logout/passkey), /api/admin/* per-entity CRUD (no /all),
PUT for updates, camelCase DTOs, reorder body {ids}.
- Should-fix 4: login dialog two-step flow (username+password -> requires2fa
-> TOTP), username input added, TOTP no longer required in step 1.
- Nits: settings panel initializes form from store data directly (no
useEffect sync setState); admin data in zustand store; bookmark HTML
import dedupes by name/URL.
- Enable biome tailwindDirectives CSS parser; keep web build in monorepo CI.
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-185 范围 1–3(前端迁入仓库 + 4 项 should-fix + 2 项 nit)。范围 4(对接真后端联调)按 Mike 裁定延后,等后端链收口后再做。
改动摘要
web/:nav-app.zip 的 SPA 迁入 monorepoweb/(src/、public/、design-system/、shadcnui/组件、components.json),保留design-system/nav/MASTER.md与MASTER.generated-by-search.md生成留痕;web/package.json接入 pnpm workspace、tsconfig.json(TS7 无baseUrl,paths直写@/*)、vite.config.ts(react + tailwindcss 插件 +@alias)。web/,未改ci.yml/deploy.yml)。仅对根biome.json加一行css.parser.tailwindDirectives(Tailwind v4 CSS 解析所需);pnpm-workspace.yaml由 pnpm 自动加minimumReleaseAgeExclude: react-hook-form@7.91.0。4 项 should-fix 落地
web/src/lib/api.ts、web/src/lib/mockDb.ts):移除api.ts:8静态import { mockDb };改为import.meta.env.DEV下动态import()。生产构建死代码消除,web/dist/字符串检索无internal.example/mockDb/nav1234占位数据。GET /api/private消费对齐(web/src/lib/types.ts、web/src/components/public-page.tsx):PrivateData与PublicData同结构(SiteData:categories/searchEngines/settings);登录后直接以privateData.categories作全量列表,去掉[...public, ...private]拼接;私有标识由「全量里有、公开列表没有」推导(注:契约/api/private分类 DTO 不含visibility,见下方说明)。web/src/lib/api.ts):认证改/api/auth/login、/api/auth/2fa/verify、/api/auth/logout、/api/auth/passkey/authenticate/options|verify;后台无/api/admin/all(各实体独立 GET + 合并为adminListAll());更新改PUT;DTO 全 camelCase(sortOrder/categoryId/iconUrl/urlTemplate/isDefault/siteTitle/backgroundUrl/searchEngines/columns);reorder 传{ids}。web/src/components/login-dialog.tsx):第一步 username+password,后端返回requires2fa才进第二步 TOTP;去掉第一步 TOTPrequired。2 项 nit
web/src/lib/nav-store.ts增adminData/loadAdmin,后台数据走 store 直接初始化;settings-panels.tsx去掉useEffect(() => setForm(settings), [settings])同步 setState,改为useState(settings)直初始化。web/src/lib/bookmarks.tsHTML 导入批量写入前按同名/同 URL 排重。自测证据
pnpm lint:0 error(28 条 style/complexity 级 warning,非阻塞)。pnpm format:check:通过(89 files)。pnpm typecheck:通过(web + worker)。pnpm build:通过(web 2494 模块 + worker)。pnpm test:20 passed / 0 failed。web/dist/无internal.example/svc-a|b|c/nav1234/mockDb。需 Mike 留意的契约说明(不私改,仅报告)
/api/public与/api/private的分类/链接 DTO 不含visibility(docs/api-contract.md的分类对象只有id/name/icon/sortOrder/links)。should-fix ONE-168 nav v1 子单 A:后端与仓库骨架(D1 schema、鉴权、三组 API、setup) #2 原文「按 visibility 判断私有标识」因此无法直接做,我改用「全量里有、公开列表没有」推导私有分类,未造假数据。若希望/api/private直接带visibility,需后端契约补充(归 Daniel/父单裁决)。links的sort_order是全局排序(listLinks按sort_order全局 ORDER BY),POST /api/admin/links/reorder契约只收{ids};分类内拖拽排序在前端重建全量 ids 后提交,属范围 4 联调时重点核对的点。