Files
ModelRouter/Makefile
JianFeeeee c309448414 feat(webui): Mono theme — pure white in light mode, pure black in dark mode
Adds a fourth accent alongside sakura/ocean/violet. Unlike those it is not just a
different hue: the coloured themes are glass surfaces (translucent cards with
backdrop-filter) floating over an animated gradient-mesh background, so setting
--card:#ffffff there still renders as a tinted grey. Mono therefore also switches
off the translucency and hides the blobs, so #ffffff is actually #ffffff and
#000000 is actually #000000, with greys carrying the hierarchy that hue carries
elsewhere. A side effect worth having: no backdrop-filter and no animated blobs
makes it the cheapest theme to render, which helps on weak GPUs and over remote
desktops.

Both light and dark variable blocks are defined, so the existing light/dark
toggle drives it with no extra wiring: light -> white, dark -> black.

Also fixes a latent theme bug found while checking contrast on black: the active
chart's grid baseline assigned the literal string "var(--line)" to
ctx.strokeStyle. Canvas 2D does not resolve CSS custom properties, so that was an
invalid colour the browser ignored, leaving the previous fillStyle (black) — an
invisible baseline on every dark theme. Colours used on a canvas now go through a
cssVar() helper.

Tests: TestUIThemeMatrix asserts every accent defines BOTH a light and a dark
block plus a picker button (a half-defined theme shows up as unreadable text, not
as an error); TestUIMonoThemeIsFlat pins the opaque surfaces and disabled blobs;
TestUICanvasColorsResolveVars fails if any ctx.strokeStyle/fillStyle is handed a
raw var().

Unrelated packaging fix in the same commit: dist:linux only built deb+AppImage
while build.linux.target listed rpm too, so `make gui-dist` silently skipped the
rpm that release builds are expected to produce. Makefile/README wording updated
to match.
2026-08-30 10:04:53 +08:00

72 lines
2.5 KiB
Makefile

.PHONY: all build test gui gui-dev gui-dist gui-deb gui-win gui-win-docker help clean
# ModelRouter - single-binary gateway + optional Electron desktop GUI (embedded core)
export BINARY
BINARY=llmsproxy
export BUILD_DIR
BUILD_DIR=build
export GUI_DIR
GUI_DIR=cmd/gui
VERSION ?= $(shell git describe --tags --dirty 2>/dev/null || echo "0.1.0")
# Clean env for GUI packaging: the host may have LD_LIBRARY_PATH polluted by
# third-party runtimes (e.g. /opt/cangjie) which electron-builder bakes into
# the produced binary's DT_RPATH/dep resolution -> the packaged app then
# SIGSEGVs inside ld.so on clean machines. Strip it for every pack step.
CLEAN_PACK_ENV = env -u LD_LIBRARY_PATH
all: build
# ---- core binary (server users / embedded core) ----
build:
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=1 go build -tags luajit -trimpath -o $(BUILD_DIR)/$(BINARY) ./cmd/llmsproxy
@echo "Built: $(BUILD_DIR)/$(BINARY) ($(VERSION))"
# ---- GUI (Electron) ----
gui:
@cd $(GUI_DIR) && npm start
gui-dev:
@cd $(GUI_DIR) && npm run dev
# build the embedded core into the GUI, then run electron-builder
# targets: deb + rpm + AppImage (linux); rpm needs system rpmbuild
# NOTE: run in a clean env (no LD_LIBRARY_PATH pollution) so the packaged
# binary does not link against host-only libs and crash on user machines.
gui-dist:
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:linux
# deb only (for local sharing), rpm needs rpmbuild
gui-deb:
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:debian
# windows nsis installer: host-built core (needs apt install gcc-mingw-w64-x86-64 + wine)
gui-win:
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:win
# windows nsis installer: full cross-build in docker (self-sufficient, no host mingw)
gui-win-docker:
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) ./scripts/dist-win-docker.sh
gui-dist-dir:
@cd $(GUI_DIR) && $(CLEAN_PACK_ENV) npm run dist:dir
test:
go test ./...
clean:
rm -rf $(BUILD_DIR) cmd/build cmd/gui/dist cmd/gui/build/gui-dist cmd/gui/bin
help:
@echo "Targets:"
@echo " make build build core binary (luajit)"
@echo " make gui run desktop GUI (dev)"
@echo " make gui-dev run GUI with devtools"
@echo " make gui-dist build deb + rpm + AppImage (linux)"
@echo " make gui-deb build deb only"
@echo " make gui-win build Windows nsis (needs host mingw + wine)"
@echo " make gui-win-docker build Windows nsis all-in-docker (no host mingw needed)"
@echo " make test run go tests"
@echo " make clean remove build dirs and packaged installers (build/, cmd/build/, cmd/gui/dist/)"