mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-01 19:41:57 +00:00
Introduce runtime frontend theme switching so administrators can switch
between the new frontend (Radix UI + Tailwind) and the classic frontend
(Semi Design) from the settings page without restarting the server.
Directory restructuring:
- Move new frontend from web/ to web/default/
- Move classic frontend from web/old/ to web/classic/
- One-frontend-per-folder layout for extensibility
Backend (injection pattern):
- Add setting/system_setting/theme.go with GlobalConfig.Register("theme")
so the DB key "theme.frontend" is handled automatically by
handleConfigUpdate — no switch-case in updateOptionMap needed
- Use atomic.Value in common.GetTheme()/SetTheme() for lock-free
concurrent reads on the hot path (static file middleware)
- Add themeAwareFileSystem that delegates to the correct embedded FS
based on the current theme at request time
- Embed both frontends into the binary via go:embed
- Add controller validation for theme.frontend values
- Expose theme in GET /api/status response
Frontend settings UI:
- New frontend: add "Frontend Theme" select in System Information section
using Radix UI Select + react-hook-form + Zod validation
- Classic frontend: add "前端主题" select in Personalization section
using Semi Design Form.Select
Build system:
- Update Dockerfile with multi-stage builds for both frontends
- Update Makefile with separate build targets for each frontend
- Update GitHub Actions release workflow for dual frontend builds
i18n:
- New frontend: add translations for all 6 locales (en/zh/fr/ja/ru/vi)
- Classic frontend: add translations for all 7 locales (en/zh-TW/ja/fr/ru/vi)
- Fix zh "AI Proxy Library" → "AI 代理库"
Documentation:
- Update CLAUDE.md, AGENTS.md, .cursor/rules/project.mdc to reflect
the new web/default/ and web/classic/ directory structure
36 lines
1.1 KiB
Makefile
36 lines
1.1 KiB
Makefile
FRONTEND_DIR = ./web/default
|
|
FRONTEND_CLASSIC_DIR = ./web/classic
|
|
BACKEND_DIR = .
|
|
|
|
.PHONY: all build-frontend build-frontend-classic build-all-frontends start-backend dev dev-api dev-web dev-web-classic
|
|
|
|
all: build-all-frontends start-backend
|
|
|
|
build-frontend:
|
|
@echo "Building default frontend..."
|
|
@cd $(FRONTEND_DIR) && bun install && DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat ../../VERSION) bun run build
|
|
|
|
build-frontend-classic:
|
|
@echo "Building classic frontend..."
|
|
@cd $(FRONTEND_CLASSIC_DIR) && bun install && VITE_REACT_APP_VERSION=$(cat ../../VERSION) bun run build
|
|
|
|
build-all-frontends: build-frontend build-frontend-classic
|
|
|
|
start-backend:
|
|
@echo "Starting backend dev server..."
|
|
@cd $(BACKEND_DIR) && go run main.go &
|
|
|
|
dev-api:
|
|
@echo "Starting backend services (docker)..."
|
|
@docker compose -f docker-compose.dev.yml up -d
|
|
|
|
dev-web:
|
|
@echo "Starting frontend dev server..."
|
|
@cd $(FRONTEND_DIR) && bun install && bun run dev
|
|
|
|
dev-web-classic:
|
|
@echo "Starting classic frontend dev server..."
|
|
@cd $(FRONTEND_CLASSIC_DIR) && bun install && bun run dev
|
|
|
|
dev: dev-api dev-web
|