diff --git a/AGENTS.md b/AGENTS.md index 442252a..88e8172 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,7 +43,7 @@ FLVX (formerly Flux Panel) is a traffic forwarding management system built on a ## CONVENTIONS -- `Authorization` header carries the raw JWT token (no `Bearer` prefix) between `vite-frontend/` and `springboot-backend/`. +- `Authorization` header carries the raw JWT token (no `Bearer` prefix) between `vite-frontend/` and `go-backend/`. - `go-gost/` uses `replace github.com/go-gost/x => ./x` and `go-gost/x/` is also its own Go module. ## ANTI-PATTERNS (THIS PROJECT) @@ -60,7 +60,7 @@ docker compose -f docker-compose-v6.yml up -d ./install.sh # Local dev (per subproject) -(cd springboot-backend && mvn clean package) +(cd go-backend && make build) (cd vite-frontend && npm run dev) (cd go-gost && go run .) ``` diff --git a/go-backend/paneld b/go-backend/paneld new file mode 100755 index 0000000..109dfd2 Binary files /dev/null and b/go-backend/paneld differ diff --git a/vite-frontend/AGENTS.md b/vite-frontend/AGENTS.md index 2ebe205..88ff6a1 100644 --- a/vite-frontend/AGENTS.md +++ b/vite-frontend/AGENTS.md @@ -10,22 +10,36 @@ Web management console for FLVX (formerly Flux Panel). ``` vite-frontend/ ├── src/ -│ ├── pages/ # Route views (some very large single-file pages) -│ ├── components/ # Reusable UI parts -│ ├── layouts/ # Admin vs H5 layouts -│ ├── api/ # API functions + axios wrapper +│ ├── api/ # Axios wrapper + typed endpoint helpers +│ ├── components/ # Shared UI components (HeroUI based) │ ├── config/ # Site config (title, repo, version) -│ └── utils/ # Auth/JWT + WebView helpers +│ ├── layouts/ # Admin vs H5 page chrome +│ ├── pages/ # Route views (many large single-file pages) +│ ├── utils/ # Auth/JWT + WebView helpers +│ ├── App.tsx # Routes + ProtectedRoute + H5 layout selection +│ ├── main.tsx # ReactDOM + Providers (HeroUI, Theme, Toast) +│ └── provider.tsx # Context provider wrapper ├── vite.config.ts # base '/', host 0.0.0.0:3000; build minify/treeshake disabled ├── eslint.config.mjs # ESLint 9 flat config └── package.json ``` +## WHERE TO LOOK +| Task | Location | Notes | +|------|----------|-------| +| **Route definitions** | `src/App.tsx` | React Router v6; H5 detection logic | +| **API Client** | `src/api/network.ts` | Sets `Authorization` header (raw token) | +| **Endpoint Calls** | `src/api/index.ts` | Thin `Network.post` wrappers | +| **Login Flow** | `src/pages/index.tsx` | Calls `login()`, stores `localStorage.token` | +| **Auth Logic** | `src/utils/auth.ts` | `isAdmin()` checks `role_id == 0` | +| **Token Decoding** | `src/utils/jwt.ts` | Checks `exp` vs current time | +| **WebView Logic** | `src/utils/panel.ts` | Handles panel address selection in app mode | + ## CONVENTIONS -- **Routing**: React Router v6 routes in `vite-frontend/src/App.tsx`. -- **Auth**: JWT stored as `localStorage.token`; sent as `Authorization` header (no prefix) in `vite-frontend/src/api/network.ts`. -- **Base URL**: Defaults to `/api/v1/` (or `VITE_API_BASE`); WebView mode selects a panel address via `vite-frontend/src/utils/panel.ts`. -- **UI**: HeroUI provider + theme + toast wired in `vite-frontend/src/provider.tsx`. +- **Auth**: JWT stored as `localStorage.token`. Sent in `Authorization` header (no "Bearer" prefix). +- **API**: Default base URL is `/api/v1/`. +- **WebView**: In WebView mode, base URL is derived from selected panel address. If unset, API returns `code: -1`. +- **Routing**: URL query param `h5=true` forces mobile layout. ## COMMANDS ```bash diff --git a/vite-frontend/src/AGENTS.md b/vite-frontend/src/AGENTS.md deleted file mode 100644 index 20d404c..0000000 --- a/vite-frontend/src/AGENTS.md +++ /dev/null @@ -1,38 +0,0 @@ -# VITE FRONTEND (src) KNOWLEDGE BASE - -## OVERVIEW -React app entry + routing + providers. This is where UI architecture decisions live. - -## STRUCTURE -``` -vite-frontend/src/ -├── main.tsx # ReactDOM + BrowserRouter + Provider -├── provider.tsx # HeroUI + theme + toaster + i18n wrapper -├── App.tsx # Routes + ProtectedRoute + H5 layout selection -├── api/ # Axios wrapper + typed endpoint helpers -├── pages/ # Route views (large) -├── layouts/ # Admin/H5 page chrome -├── components/ # Shared UI components -├── utils/ # JWT parsing + auth helpers + WebView utilities -└── styles/ # globals.css -``` - -## WHERE TO LOOK -| Task | Location | Notes | -|------|----------|-------| -| Route definitions | `vite-frontend/src/App.tsx` | React Router v6 | -| API client baseURL | `vite-frontend/src/api/network.ts` | `/api/v1/` + token header | -| Token decoding | `vite-frontend/src/utils/jwt.ts` | Checks `exp` vs now | -| Role checks | `vite-frontend/src/utils/auth.ts` | `isAdmin()` is `role_id == 0` | -| WebView integration | `vite-frontend/src/api/network.ts` | Panel address selection in WebView mode | - -## CONVENTIONS -- Token is stored in `localStorage.token` and sent as `Authorization` header (raw token string). -- H5 mode detection is in `vite-frontend/src/App.tsx` (screen/user-agent/query param `h5=true`). - -## COMMANDS -```bash -cd vite-frontend -npm run dev -npm run lint -``` diff --git a/vite-frontend/src/api/AGENTS.md b/vite-frontend/src/api/AGENTS.md deleted file mode 100644 index 35433a7..0000000 --- a/vite-frontend/src/api/AGENTS.md +++ /dev/null @@ -1,16 +0,0 @@ -# VITE FRONTEND (src/api) KNOWLEDGE BASE - -## OVERVIEW -API client layer. Wraps axios and normalizes backend responses (`{ code, msg, data }`). - -## WHERE TO LOOK -| Task | Location | Notes | -|------|----------|-------| -| Axios wrapper | `vite-frontend/src/api/network.ts` | Sets `axios.defaults.baseURL`; adds `Authorization` header | -| BaseURL init (WebView vs web) | `vite-frontend/src/api/network.ts` | WebView mode calls `getPanelAddresses()` | -| Endpoint functions | `vite-frontend/src/api/index.ts` | Mostly `Network.post("/…")` | - -## CONVENTIONS -- Default baseURL is `/api/v1/` (or `${VITE_API_BASE}/api/v1/`). -- In WebView mode, baseURL is derived from the selected panel address; if unset, requests return `code: -1` with a “set panel address” message. -- 401 responses clear localStorage and redirect to `/`. diff --git a/vite-frontend/src/pages/AGENTS.md b/vite-frontend/src/pages/AGENTS.md deleted file mode 100644 index ee301ab..0000000 --- a/vite-frontend/src/pages/AGENTS.md +++ /dev/null @@ -1,30 +0,0 @@ -# VITE FRONTEND (pages) KNOWLEDGE BASE - -## OVERVIEW -Route views rendered by `vite-frontend/src/App.tsx`. Several pages are large, single-file screens. - -## STRUCTURE -``` -vite-frontend/src/pages/ -├── index.tsx # Login + captcha flow -├── dashboard.tsx -├── forward.tsx # Large -├── tunnel.tsx # Large -├── node.tsx # Large -├── user.tsx # Large -├── config.tsx -├── limit.tsx -├── profile.tsx -├── settings.tsx -└── change-password.tsx -``` - -## WHERE TO LOOK -| Task | Location | Notes | -|------|----------|-------| -| Login flow | `vite-frontend/src/pages/index.tsx` | Calls `login()` and stores `localStorage.token` | -| API calls | `vite-frontend/src/api/index.ts` | Thin wrappers around `Network.post` | -| Token expiration behavior | `vite-frontend/src/api/network.ts` | Clears localStorage + redirects on 401 | - -## CONVENTIONS -- Pages call API wrappers from `vite-frontend/src/api/index.ts` (most endpoints are POST).