mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-12-06 00:03:11 +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
50 lines
1.5 KiB
Docker
50 lines
1.5 KiB
Docker
FROM oven/bun:1@sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7 AS builder
|
|
|
|
WORKDIR /build
|
|
COPY web/default/package.json .
|
|
COPY web/default/bun.lock .
|
|
RUN bun install
|
|
COPY ./web/default .
|
|
COPY ./VERSION .
|
|
RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
|
|
|
|
FROM oven/bun:1@sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7 AS builder-classic
|
|
|
|
WORKDIR /build
|
|
COPY web/classic/package.json .
|
|
COPY web/classic/bun.lock .
|
|
RUN bun install
|
|
COPY ./web/classic .
|
|
COPY ./VERSION .
|
|
RUN VITE_REACT_APP_VERSION=$(cat VERSION) bun run build
|
|
|
|
FROM golang:1.26.1-alpine@sha256:2389ebfa5b7f43eeafbd6be0c3700cc46690ef842ad962f6c5bd6be49ed82039 AS builder2
|
|
ENV GO111MODULE=on CGO_ENABLED=0
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64}
|
|
ENV GOEXPERIMENT=greenteagc
|
|
|
|
WORKDIR /build
|
|
|
|
ADD go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
COPY --from=builder /build/dist ./web/default/dist
|
|
COPY --from=builder-classic /build/dist ./web/classic/dist
|
|
RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
|
|
|
|
FROM debian:bookworm-slim@sha256:f06537653ac770703bc45b4b113475bd402f451e85223f0f2837acbf89ab020a
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates tzdata libasan8 wget \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& update-ca-certificates
|
|
|
|
COPY --from=builder2 /build/new-api /
|
|
EXPOSE 3000
|
|
WORKDIR /data
|
|
ENTRYPOINT ["/new-api"]
|