Repository navigation
ONE-422: 前端 /setup 页面 + 管理面「系统管理」选项卡(ONE-425) - #8
Merged
Merged
Conversation
- 新增 /setup 路由(App 按 pathname 识别,保留 #admin 哈希路由), SetupPage 形态状态机:loading / error / disabled / 未初始化 / 已初始化 - 未初始化与已初始化是两个独立表单组件 + 不同 key(DOM 节点必换): 密钥框 name/id=setup-secret、type=password、autocomplete=off; 用户名框 name=username、autocomplete=username;建号密码框 name=password、 autocomplete="new-password";确认密码框同名语义 - 密钥只走 X-Setup-Secret 请求头,提交后立即清空 state 与输入框, 不写 localStorage/日志/URL;403/429/409(detail 原文)/其余通用错误分别文案 - disabled 形态只给提示 + 去登录入口,DOM 无任何密钥表单 - 管理面新增「系统管理」选项卡:数据库维护(tablePrefix + 账本已记录迁移、 「检查并升级数据库」进行态与逐条 applied/skipped 结果、409 detail 原文留在区内) 与 setup 页面开关(Switch → PUT 后回读确认 + 新标签打开 /setup 链接) - lib/api.ts 增加 setup 三件套客户端与 ApiError.detail;请求头合并顺序修正
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-422 setup 三件套的前端部分(子单 ONE-425):新增
/setup页面(密钥升级 / 未初始化建号),管理面新增「系统管理」选项卡(数据库维护 + setup 页面开关)。基线 main1181b4f,接口按父单 §3 冻结契约对接(Stage 1 后端在 PR #7)。改动文件
web/src/App.tsxsetup:readRoute()优先读 pathname(/setup),其余保持既有#admin哈希路由;新增navigate()做站内跳转(pushState + popstate/hashchange 同步)web/src/components/setup/setup-page.tsx(新)/setup页面与形态状态机(loading / error / disabled / 未初始化 / 已初始化)web/src/components/setup/migration-results.tsx(新)web/src/components/admin/system-panel.tsx(新)web/src/components/admin/admin-page.tsxweb/src/lib/api.tsgetSetupState/runSetupUpgrade/runOwnerSetup/adminRunSetup/adminGetSystem/adminSetSetupPage);ApiError增detail(409 显示后端原文);修正 request 里 init 覆盖 headers 的顺序web/src/lib/types.tsSetupState/SetupMigration/SetupResult/SetupOwnerResult/AdminSystem(对齐 workertypes.ts)契约落实(逐条)
LoginDialog),DOM 中零form/ 零input。POST /api/auth/setup;成功展示 tablePrefix + 逐条 applied/skipped + 首页/管理面入口(会话已签发,loadPrivate()同步 store 登录态,进入管理面直接进后台)。SETUP_SECRET一项,提交POST /api/setup;成功展示同一份迁移结果 + 明示「本次未创建或修改任何账号」。detail原文、其余→通用错误;提交瞬间即清空密钥 state 与输入框(失败也清);密钥只走X-Setup-Secret头,不入 URL / localStorage / 日志。<form>;密钥框id/name=setup-secret、type=password、autocomplete=off(不是current-password);用户名name=username/autocomplete=username;建号密码name=password/autocomplete=new-password;两种形态是两个独立组件 +key="setup-owner-form"/key="setup-upgrade-form",切换时 DOM 节点必换。GET /api/admin/system的tablePrefix与ledger;「检查并升级数据库」调POST /api/admin/setup,执行中禁用 + 进行态,完成后区内列逐条 migrations 并 toast;409 时把detail原文留在区内。Switch绑定setupPageEnabled→PUT /api/admin/system/setup-page保存后回读确认;旁注文案「关闭后 /setup 只显示已关闭提示;管理面升级按钮与密钥接口不受此开关影响。」;「打开 setup 页面」新标签打开/setup。验证
pnpm typecheck/pnpm build/pnpm lint(仅既有 28 条 useImportType 等 warning,无 error)/pnpm format:check/pnpm test(worker 39 例)全绿。USE_MOCK=false,真实 fetch),桩后端提供四态与错误码,35 项断言全过,覆盖未初始化/已初始化/disabled/状态端点失败四种形态、403/429/409 文案、密钥只走请求头且不入 storage、DOM 换形态、管理面升级与开关回读。验证脚本在 workdir(未入库)。回滚
纯前端新增/改动,revert 本 PR 即恢复原状(无迁移、无数据变更)。