Skip to content

前端:新增 /setup 初始化页面 + 后台开关与「检查并升级数据库」按钮 - #127

Merged
todosdev[bot] merged 2 commits into
mainfrom
tds/conv-01a14da1-61fe-73d5-a5dd-c00dc699f45b
Oct 18, 2026
Merged

todosdev[bot] merged 2 commits into
mainfrom
tds/conv-01a14da1-61fe-73d5-a5dd-c00dc699f45b

Conversation

@todosdev

@todosdev todosdev Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a public /setup initialization page so new installs can initialize/upgrade the database from the browser instead of curl, gated by a new setup_page_enabled admin setting.
  • Adds a "允许访问初始化页面" toggle and a "检查并升级数据库" button to a new admin System Settings page, wired into the admin nav.
  • Ships the accompanying zh/en i18n strings. Backend endpoints (GET /api/setup/state, POST /api/admin/setup, setup_page_enabled) are provided by the parallel backend task and already on main.

Changes

  • web/src/pages/setup/SetupPage.tsx (new) — public /setup route with four states: loading, disabled (admin turned the page off), form (SETUP_SECRET input + submit), and done. Submits POST /api/setup with the X-Setup-Secret header and maps 403 → wrong-secret, 429 → rate-limited, alreadyInitialized → "already initialized" copy vs. fresh-init success.
  • web/src/pages/admin/AdminSystemPage.tsx — repurposed the dead combined settings file into a focused System Settings page: setup_page_enabled toggle (saved via PUT /api/admin/system/settings) and a database-maintenance card that calls POST /api/admin/setup, showing up-to-date/initialized on success and status-mapped, non-leaky errors on failure.
  • web/src/App.tsx — registers /setup (public) and /admin/system (admin-only) routes.
  • web/src/pages/admin/AdminPage.tsx — adds the "系统设置" tab (desktop tabs + mobile submenu).
  • web/src/lib/api.ts — new setupApi (state/run) using raw fetch for the X-Setup-Secret header and status-coded errors, plus the SetupResult type.
  • web/src/types/index.ts — SystemSettings.setup_page_enabled?.
  • web/src/locales/{en,zh}.json — setup.* and admin.setupPage* / admin.db* strings.

Testing

  • pnpm install --frozen-lockfile, pnpm lint, pnpm format:check, pnpm typecheck, pnpm build all pass (lint shows only two pre-existing warnings in worker/src/routes/items.ts and PasswordPromptDialog.tsx, unrelated to this change).
  • End-to-end manual walkthrough (toggle off/on, wrong-secret 403, admin button) is deferred until backend fix(deps): update dependency react-i18next to v17 #12 is deployed to production, since the endpoints it adds are what the page drives.

Todos and others added 2 commits October 18, 2026 14:16
- Add public /setup page driven by GET /api/setup/state and POST /api/setup
  (X-Setup-Secret header), with disabled/loading/form/done states and
  403/429 error mapping.
- Add setup_page_enabled toggle and "check and upgrade database" button to
  the admin system settings page (POST /api/admin/setup).
- Wire /setup and /admin/system routes and the admin "system" tab.
- Add zh/en i18n strings for the new UI.

Checkpoint: 3iuwy9uzxonUxglhH3OGM
@todosdev
todosdev Bot merged commit 3ba91e5 into main Oct 18, 2026
@mapxn
mapxn deleted the tds/conv-01a14da1-61fe-73d5-a5dd-c00dc699f45b branch October 18, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant