mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #4541] [MERGED] feat(frontend): TanStack Query + React Router migration & in-panel API docs #5714
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5714
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/4541
Author: @MHSanaei
Created: 5/24/2026
Status: ✅ Merged
Merged: 5/24/2026
Merged by: @MHSanaei
Base:
main← Head:feat/tanstack-query-react-router📝 Commits (10+)
538473bfeat(frontend): introduce TanStack Query with status pollingd9def73feat(frontend): collapse panel pages into a single React Router SPAdff509bfeat(frontend): migrate useNodes to TanStack Querybbb7af6feat(frontend): migrate useAllSetting to TanStack Query8643154feat(frontend): route useInbounds fetches through TanStack Query967b9abfeat(frontend): migrate useClients to TanStack Query6a6f44cfeat(frontend): route useXraySetting fetches through TanStack Query77099f9fix(frontend): restore per-route document titles in the SPA47ef765feat(api-docs): expose OpenAPI spec + render Swagger UI in paneld67eb49style(api-docs): dark/ultra theme for Swagger UI📊 Changes
60 files changed (+8950 additions, -2348 deletions)
View changed files
➖
frontend/api-docs.html(+0 -13)➖
frontend/clients.html(+0 -13)➖
frontend/inbounds.html(+0 -13)📝
frontend/index.html(+2 -2)➖
frontend/nodes.html(+0 -13)📝
frontend/package-lock.json(+2345 -263)📝
frontend/package.json(+9 -3)➕
frontend/public/openapi.json(+4944 -0)➕
frontend/scripts/build-openapi.mjs(+218 -0)➖
frontend/settings.html(+0 -13)➕
frontend/src/api/QueryProvider.tsx(+16 -0)➕
frontend/src/api/queries/useAllSettings.ts(+67 -0)➕
frontend/src/api/queries/useNodeMutations.ts(+63 -0)➕
frontend/src/api/queries/useNodesQuery.ts(+108 -0)➕
frontend/src/api/queries/useStatusQuery.ts(+33 -0)➕
frontend/src/api/queryKeys.ts(+30 -0)➕
frontend/src/api/websocketBridge.ts(+77 -0)📝
frontend/src/components/AppSidebar.tsx(+24 -28)➖
frontend/src/entries/clients.tsx(+0 -28)➖
frontend/src/entries/inbounds.tsx(+0 -28)...and 40 more files
📄 Description
Summary
Migrates the panel frontend from a 9-entry MPA with hand-rolled
useState/useEffecthooks to a single React Router SPA backed by TanStack Query, and replaces the API-docs page with a Swagger UI rendering an auto-generated OpenAPI 3 spec.Phase 1 — TanStack Query foundation
QueryClientsingleton with sensible defaults (staleTime 30s, refetchOnWindowFocus, retry 1) + dev-only DevToolsfrontend/src/api/queryKeys.tsuseStatusQueryas the proof-of-concept (2s polling)Phase 2 — Multi-entry → SPA
index.html,login.html,subpage.htmlcreateBrowserRouterwith lazy-loaded page chunks/panel/*collapses to one catch-all servingindex.htmlPanelLayoutdispatches toqueryClient(replaces per-pageuseWebSocketglue)AppSidebaruses<Link>/useNavigate— no more full-page reloads between panel routesPhase 3 — Hook migrations (one commit per resource)
useNodesQuery+useNodeMutationsuseAllSettingsQuery+ save mutation; draft state stays localkeepPreviousData+ 9 mutations; in-place WS merges preservedPhase 4 — Xray (partial)
Editor state and 1s dirty-check polling kept; only network calls (config, save, test-outbound, reset, restart, default-config, outbounds traffic) moved to Query.
Phase 5 — Per-route document titles
SPA collapse broke per-page
<title>— addedusePageTitlehook with a route→title map, mounted inPanelLayout.Phase 6 — In-panel API docs
frontend/scripts/build-openapi.mjsconverts the existingendpoints.jsinto an OpenAPI 3.0.3 spec (106 paths, 12 tags, Bearer + cookie security)ApiDocsPagerendersswagger-ui-reactagainst that URL — gives readable docs + Try-it-out tester + Postman-compatible spec, replacing the hand-written endpoint cardsPhase 7 — Dark/ultra theme for Swagger UI
Swagger ships no dark theme, so every visual surface gets an override scoped to
.api-docs-page.is-dark/.is-ultra: opblocks, tables, model boxes, form inputs, code blocks, modals, Servers dropdown (with a custom light-fill SVG arrow), per-endpoint padlocks and expand chevrons. Method chips kept their semantic colors.Test plan