From 5e0cbb026b860efe1b5d21523531b21864341988 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Thu, 16 Jul 2026 21:45:57 +0800 Subject: [PATCH] refactor(webui): establish offline typography foundations Remove runtime requests to external font services and make the default sans and monospace stacks rely entirely on locally available platform fonts. Introduce explicit metadata and micro text tokens for dense technical content, disable synthetic font faces globally, and update the appearance selector so every bundled font choice accurately describes its local source. --- packages/webui/index.html | 3 --- packages/webui/src/contexts/ThemeContext.tsx | 12 ++++++------ packages/webui/src/index.css | 12 ++++++++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/webui/index.html b/packages/webui/index.html index d48d02ce..4ec14842 100644 --- a/packages/webui/index.html +++ b/packages/webui/index.html @@ -49,9 +49,6 @@ } catch (e) { /* ignore — fall back to default theme */ } })(); - - -
diff --git a/packages/webui/src/contexts/ThemeContext.tsx b/packages/webui/src/contexts/ThemeContext.tsx index e7d73367..0a8d2d75 100644 --- a/packages/webui/src/contexts/ThemeContext.tsx +++ b/packages/webui/src/contexts/ThemeContext.tsx @@ -66,15 +66,15 @@ export const POLL_INTERVAL_OPTIONS = [ export interface FontSpec { id: string; label: string; stack: string } export const FONT_SANS_OPTIONS: FontSpec[] = [ - { id: 'default', label: '默认 (Inter)', stack: "'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif" }, - { id: 'system', label: '系统界面', stack: "system-ui, -apple-system, 'Segoe UI', 'Noto Sans SC', sans-serif" }, - { id: 'rounded', label: '圆润', stack: "'Varela Round', 'Quicksand', 'Noto Sans SC', system-ui, sans-serif" }, - { id: 'serif', label: '衬线', stack: "Georgia, 'Songti SC', 'Noto Serif SC', serif" }, + { id: 'default', label: '默认(本地系统)', stack: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif" }, + { id: 'system', label: '平台原生', stack: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" }, + { id: 'rounded', label: '圆润(平台字体)', stack: "ui-rounded, 'SF Pro Rounded', system-ui, sans-serif" }, + { id: 'serif', label: '衬线(本地字体)', stack: "Georgia, 'Songti SC', 'STSong', serif" }, ]; export const FONT_MONO_OPTIONS: FontSpec[] = [ - { id: 'default', label: '默认 (JetBrains)', stack: "'JetBrains Mono', 'Fira Code', ui-monospace, monospace" }, - { id: 'system', label: '系统等宽', stack: "ui-monospace, 'SF Mono', Menlo, Consolas, monospace" }, + { id: 'default', label: '默认(系统等宽)', stack: "ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace" }, + { id: 'system', label: '平台等宽', stack: "ui-monospace, Menlo, Consolas, monospace" }, ]; export interface GradientSpec { id: string; label: string; css: string } diff --git a/packages/webui/src/index.css b/packages/webui/src/index.css index 0c74ff57..b665a8ab 100644 --- a/packages/webui/src/index.css +++ b/packages/webui/src/index.css @@ -150,8 +150,15 @@ --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 4px); - --font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif; - --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; + --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif; + --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace; + + /* Dense metadata is the only content allowed below Tailwind's 12px text-xs + floor. Named tokens make that exception explicit at each call site. */ + --text-meta: 0.6875rem; + --text-meta--line-height: 1rem; + --text-micro: 0.625rem; + --text-micro--line-height: 0.875rem; } @layer base { @@ -166,6 +173,7 @@ background-color: var(--background); color: var(--foreground); font-family: var(--font-sans); + font-synthesis: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; line-height: 1.5;