Repository navigation
前端:新增 /setup 初始化页面与后台「检查并升级数据库」入口 - #128
Merged
todosdev[bot] merged 2 commits intoOct 18, 2026
Merged
Conversation
added 2 commits
October 18, 2026 15:12
- Add public /setup page (state check, secret form, migration results) - Add setup_page_enabled toggle and "check & upgrade" button to admin settings - Surface Retry-After on ApiRequestError and map setup errors by status code - Add setupApi/adminApi.runSetup to the typed client plus en/zh-CN strings - Cover state, submit success, 429 and admin upgrade in node --test Checkpoint: T89ynSWY-zOYYWExTx-dD
- Return null for session-expired setup/admin errors instead of leaking untranslated text alongside AuthProvider's global toast - Fall back to setup.errorGeneric for unclassified errors, dropping the raw backend-message branch that bypassed i18n - Extract migration status label/variant and formatSetupError into pure helpers and cover them (plus session-expiry and interpolation) in node --test Checkpoint: kWYiOxJIc96_8plsowQ7v
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
/setupinitialization page matching the Zeta setup flow: readsGET /api/setup/state, shows a secret form when enabled (or a "disabled" notice), and displays per-migration results fromPOST /api/setup.setup_page_enabledtoggle in the admin settings page.apiErrorCodesmechanism.Changes
apps/web/src/App.tsx): new lazy/setuproute in the public section, ahead of the*fallback.apps/web/src/api/client.ts):SetupMigration/SetupResulttypes;setupApi.state()/setupApi.run(secret)andadminApi.runSetup();ApiRequestErrornow surfacesretryAfterparsed from theRetry-Afterheader (backward compatible).apps/web/src/pages/SetupPage.tsx): fetches state on mount, handles loading / 404 ("backend has not provided this endpoint yet") / disabled, renders a password-typed secret input (no echo), and shows migration results; submit button disables while running.apps/web/src/components/setup-migrations.tsx): renders each migration'sname+statusbadge (applied/skipped/error), with inlineerrortext for failures — reused by both the public page and the admin action.apps/web/src/pages/admin/AdminSettingsPage.tsx):setup_page_enabledtoggle (stored'0'/'1', defaults on, "only hides the page" copy) and a "Check & Upgrade Database" button callingPOST /api/admin/setupwith loading state and inline results/errors.apps/web/src/lib/setup.ts): pureresolveSetupErrormaps 400/403/404/429 (withRetry-Afterseconds)/500 and known backend codes to i18n keys; session-expired returnsnull(silent, AuthProvider shows the single global toast); unknown errors fall back to a generic key. Also holdsmigrationStatusLabel/MIGRATION_STATUS_VARIANTdisplay mappings andformatSetupError.apps/web/src/i18n/locales/en.ts,zh-CN.ts): fullsetup.*,admin.setupPage*,admin.runSetup*, andtoast.setupPage*strings in both locales; no hardcoded Chinese.apps/web/src/lib/setup.test.ts,apps/web/package.json): node --test coverage for state, submit success, 429Retry-After, admin upgrade success, error mapping (incl. session expiry + generic fallback), status label/variant display mapping, and locale completeness.Testing
pnpm check(Biome),pnpm typecheck,pnpm build, andpnpm testall pass — 44 tests green. Tests follow the existingnode --test+ stubbed-fetch style (no React renderer), so the display logic is exercised through its extracted pure functions; the components themselves are validated by the typecheck + Vite production build.