fix(frontend): make general-settings font picker actually work
The font picker in 常规设置 silently failed in three distinct ways: 1. Font family changes were invisible on macOS because 6 of the 7 options (Inter / Roboto / Segoe UI / Cascadia Code / JetBrains Mono / Fira Code) aren't installed by default and fell back to system SF. Swap the picker to a platform-aware list — Mac / Windows / Linux each see only the fonts their OS actually ships. The "third sans slot" now always serves a serif face (Georgia / Times New Roman / DejaVu Serif) so the difference is unambiguously visible instead of being three near-identical sans families. 2. Font size flipped --app-font-scale on <html>, but that variable was only consumed by a handful of TDesign tokens and the body reset, so the ~1000+ hard-coded font-size: NNpx rules across the frontend stayed put. Apply the multiplier via `zoom` on <html> so the whole document scales, then fix the 15 `100vh` rules that would overflow under zoom (html / body / #app are already height: 100%, so the descendants can use 100% too). 3. The monospace picker had no visible effect even on a working stack because `<t-input style="font-family: ...">` is forwarded to the inner <input>, but TDesign applies `font: var(--td-font-body-medium)` — a shorthand that resets font-family. Reach the real <input> / <textarea> via `:deep()` instead of inline style. Additional polish: - Add a live preview row under each picker so users can see the effect without hunting for a code block or API Info screen - Rename "等宽字体 / Monospace Font" → "代码字体 / Code Font" to match VSCode / GitHub / Notion convention; the old label was jargon - Rewrite descriptions to explain the actual purpose and scope
This commit is contained in:
@@ -192,7 +192,7 @@ html,
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: calc(14px * var(--app-font-scale, 1));
|
||||
font-size: 14px;
|
||||
font-family: var(--app-font-family);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -454,6 +454,12 @@ onUnmounted(() => {
|
||||
@error-color: var(--td-error-color);
|
||||
@table-border: var(--td-component-stroke);
|
||||
@preview-max-h: calc(100vh - 200px);
|
||||
// Note: <html> carries a `zoom` multiplier for font-size control, so 100vh
|
||||
// is evaluated against the unscaled viewport and the resulting max-height
|
||||
// may exceed the real viewport by the zoom factor (≤12.5% at "large").
|
||||
// That produces an extra bit of scroll inside the non-fullscreen preview,
|
||||
// which is acceptable for document reading. Not worth the complexity of
|
||||
// inverse-scaling here.
|
||||
@transition: all 0.2s ease;
|
||||
|
||||
// ── Shared container mixin ──
|
||||
@@ -488,13 +494,18 @@ onUnmounted(() => {
|
||||
z-index: 2002;
|
||||
}
|
||||
|
||||
/* Children use height: 100% rather than 100vh because <html> carries a
|
||||
`zoom` multiplier for font-size control; 100vh resolves against the
|
||||
unscaled viewport and then gets scaled, overshooting the screen. The
|
||||
fullscreen container is already inset 0 on all sides, so 100% resolves
|
||||
to the true viewport height. */
|
||||
.preview-pdf {
|
||||
height: 100vh;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.preview-pptx {
|
||||
height: auto;
|
||||
min-height: 100vh;
|
||||
min-height: 100%;
|
||||
overflow: visible;
|
||||
border: none;
|
||||
|
||||
@@ -505,30 +516,30 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.preview-docx {
|
||||
height: 100vh;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.docx-container {
|
||||
max-height: 100vh;
|
||||
max-height: 100%;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-image {
|
||||
min-height: 100vh;
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.image-wrapper img {
|
||||
max-height: calc(100vh - 80px);
|
||||
max-height: calc(100% - 80px);
|
||||
}
|
||||
}
|
||||
|
||||
.preview-excel .excel-container,
|
||||
.preview-markdown,
|
||||
.preview-text .code-preview {
|
||||
max-height: 100vh;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -885,7 +885,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
||||
padding: 8px;
|
||||
background: var(--td-bg-color-sidebar);
|
||||
box-sizing: border-box;
|
||||
height: 100vh;
|
||||
/* Avoid 100vh because <html> carries a `zoom` multiplier for font-size
|
||||
control; 100vh is evaluated against the unscaled viewport and then
|
||||
scaled, so at "large" the sidebar would extend past the window. The
|
||||
ancestor chain (html/body/#app/.main) is already height: 100%. */
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -5,22 +5,55 @@ import {
|
||||
migratePreferencesIntoUser,
|
||||
} from './preferenceStorage'
|
||||
|
||||
// Font options are filtered by host platform. A Windows user selecting
|
||||
// "PingFang SC" in a cross-platform list would see Microsoft YaHei anyway
|
||||
// (fallback via the stack), so the labels would lie. Instead each OS
|
||||
// surfaces the fonts it actually ships.
|
||||
// Mac: system / pingfang / georgia / sans-serif
|
||||
// system / menlo / monaco / monospace
|
||||
// Windows: system / yahei / times / sans-serif
|
||||
// system / consolas / cascadia / monospace
|
||||
// Linux: system / noto-cjk / dejavu-serif / sans-serif
|
||||
// system / dejavu-mono / liberation-mono / monospace
|
||||
//
|
||||
// The "third" sans slot on each platform is a serif face (Georgia /
|
||||
// Times New Roman / DejaVu Serif). This is intentional: on macOS the
|
||||
// system sans, PingFang, and Helvetica are all visually close enough
|
||||
// that users reported "the font doesn't change". A serif option produces
|
||||
// a genuinely distinct look, so the setting feels responsive.
|
||||
//
|
||||
// All keys live in a single union so the persisted value is stable across
|
||||
// devices; the runtime picker just hides the non-matching subset. A user
|
||||
// who moves a localStorage value (e.g. "pingfang") to a Windows machine
|
||||
// gets it validated against SANS_STACKS (which still contains the key) and
|
||||
// the font stack still works — the browser just falls back to yahei on
|
||||
// its own. Only truly unknown keys fall through to DEFAULT_SANS.
|
||||
export type FontKey =
|
||||
| 'system'
|
||||
// Mac
|
||||
| 'pingfang'
|
||||
| 'inter'
|
||||
| 'helvetica'
|
||||
| 'segoe'
|
||||
| 'roboto'
|
||||
| 'georgia'
|
||||
// Windows
|
||||
| 'yahei'
|
||||
| 'times'
|
||||
// Linux
|
||||
| 'noto-cjk'
|
||||
| 'dejavu-serif'
|
||||
// cross-platform
|
||||
| 'sans-serif'
|
||||
|
||||
export type MonoFontKey =
|
||||
| 'system'
|
||||
| 'cascadia'
|
||||
| 'jetbrains'
|
||||
| 'fira'
|
||||
// Mac
|
||||
| 'menlo'
|
||||
| 'monaco'
|
||||
// Windows
|
||||
| 'consolas'
|
||||
| 'cascadia'
|
||||
// Linux
|
||||
| 'dejavu-mono'
|
||||
| 'liberation-mono'
|
||||
// cross-platform
|
||||
| 'monospace'
|
||||
|
||||
export type FontSizeKey = 'small' | 'normal' | 'large'
|
||||
@@ -32,29 +65,41 @@ const SIZE_KEY = 'font_size'
|
||||
export const SANS_STACKS: Record<FontKey, string> = {
|
||||
system:
|
||||
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif',
|
||||
// Mac
|
||||
pingfang:
|
||||
'"PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, sans-serif',
|
||||
inter:
|
||||
'Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
helvetica:
|
||||
'"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
segoe:
|
||||
'"Segoe UI", Tahoma, Verdana, Arial, "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
roboto:
|
||||
'Roboto, "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
georgia:
|
||||
'Georgia, "Times New Roman", "Songti SC", "SimSun", serif',
|
||||
// Windows
|
||||
yahei:
|
||||
'"Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Tahoma, Arial, sans-serif',
|
||||
times:
|
||||
'"Times New Roman", Times, Georgia, "SimSun", "Songti SC", serif',
|
||||
// Linux
|
||||
'noto-cjk':
|
||||
'"Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif',
|
||||
'dejavu-serif':
|
||||
'"DejaVu Serif", "Liberation Serif", "Noto Serif", Georgia, "Times New Roman", serif',
|
||||
// cross-platform
|
||||
'sans-serif': 'sans-serif',
|
||||
}
|
||||
|
||||
export const MONO_STACKS: Record<MonoFontKey, string> = {
|
||||
system:
|
||||
'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
||||
cascadia:
|
||||
'"Cascadia Code", "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
||||
jetbrains:
|
||||
'"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
||||
fira: '"Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
||||
// Mac
|
||||
menlo: 'Menlo, Monaco, Consolas, "Courier New", monospace',
|
||||
monaco: 'Monaco, Menlo, Consolas, "Courier New", monospace',
|
||||
// Windows
|
||||
consolas: 'Consolas, "Courier New", Menlo, Monaco, monospace',
|
||||
cascadia:
|
||||
'"Cascadia Code", "Cascadia Mono", Consolas, "Courier New", monospace',
|
||||
// Linux
|
||||
'dejavu-mono':
|
||||
'"DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace',
|
||||
'liberation-mono':
|
||||
'"Liberation Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace',
|
||||
// cross-platform
|
||||
monospace: 'monospace',
|
||||
}
|
||||
|
||||
@@ -64,6 +109,65 @@ export const FONT_SCALES: Record<FontSizeKey, number> = {
|
||||
large: 1.125,
|
||||
}
|
||||
|
||||
export type Platform = 'mac' | 'windows' | 'linux'
|
||||
|
||||
/**
|
||||
* Detect the host OS so the font picker can offer options the user will
|
||||
* actually see. Prefers navigator.userAgentData (modern Chromium, Edge,
|
||||
* current Wails WebView) and falls back to the UA string — older Safari
|
||||
* and some Firefox builds still don't expose userAgentData.
|
||||
*
|
||||
* Unknown platforms fall back to Mac, which is the most common development
|
||||
* environment for this project.
|
||||
*/
|
||||
export function detectPlatform(): Platform {
|
||||
if (typeof navigator === 'undefined') return 'mac'
|
||||
|
||||
// Modern: client hints (Chromium ≥ 90, Edge, Wails WebView on Win/Mac).
|
||||
const uaData = (navigator as unknown as {
|
||||
userAgentData?: { platform?: string }
|
||||
}).userAgentData
|
||||
const hintPlatform = uaData?.platform
|
||||
if (typeof hintPlatform === 'string' && hintPlatform.length > 0) {
|
||||
const p = hintPlatform.toLowerCase()
|
||||
if (p.includes('mac')) return 'mac'
|
||||
if (p.includes('win')) return 'windows'
|
||||
if (p.includes('linux') || p.includes('android') || p.includes('chrome os')) return 'linux'
|
||||
}
|
||||
|
||||
// Fallback: parse the UA string. Matches Safari, older Firefox, WebView.
|
||||
const ua = navigator.userAgent.toLowerCase()
|
||||
if (ua.includes('mac os x') || ua.includes('macintosh') || ua.includes('iphone') || ua.includes('ipad')) {
|
||||
return 'mac'
|
||||
}
|
||||
if (ua.includes('windows')) return 'windows'
|
||||
if (ua.includes('linux') || ua.includes('android') || ua.includes('cros')) return 'linux'
|
||||
|
||||
return 'mac'
|
||||
}
|
||||
|
||||
const SANS_KEYS_BY_PLATFORM: Record<Platform, FontKey[]> = {
|
||||
mac: ['system', 'pingfang', 'georgia', 'sans-serif'],
|
||||
windows: ['system', 'yahei', 'times', 'sans-serif'],
|
||||
linux: ['system', 'noto-cjk', 'dejavu-serif', 'sans-serif'],
|
||||
}
|
||||
|
||||
const MONO_KEYS_BY_PLATFORM: Record<Platform, MonoFontKey[]> = {
|
||||
mac: ['system', 'menlo', 'monaco', 'monospace'],
|
||||
windows: ['system', 'consolas', 'cascadia', 'monospace'],
|
||||
linux: ['system', 'dejavu-mono', 'liberation-mono', 'monospace'],
|
||||
}
|
||||
|
||||
/** Keys visible in the sans-serif picker on the current platform. */
|
||||
export function visibleSansKeys(platform: Platform = detectPlatform()): FontKey[] {
|
||||
return SANS_KEYS_BY_PLATFORM[platform]
|
||||
}
|
||||
|
||||
/** Keys visible in the monospace picker on the current platform. */
|
||||
export function visibleMonoKeys(platform: Platform = detectPlatform()): MonoFontKey[] {
|
||||
return MONO_KEYS_BY_PLATFORM[platform]
|
||||
}
|
||||
|
||||
const DEFAULT_SANS: FontKey = 'system'
|
||||
const DEFAULT_MONO: MonoFontKey = 'system'
|
||||
const DEFAULT_SIZE: FontSizeKey = 'normal'
|
||||
@@ -120,7 +224,18 @@ function applyFont() {
|
||||
lastApplied.mono = monoStack
|
||||
}
|
||||
if (lastApplied.scale !== scale) {
|
||||
root.style.setProperty('--app-font-scale', scale)
|
||||
// Apply size via CSS zoom on <html> so the multiplier reaches every
|
||||
// element — including the ~1000+ hard-coded `font-size: NNpx` rules
|
||||
// scattered across the frontend. The previous approach set
|
||||
// `--app-font-scale` and relied on `calc(NNpx * var(--app-font-scale))`,
|
||||
// but calc() only runs where the variable is consumed (a few TDesign
|
||||
// tokens plus the body reset), so users saw only parts of the UI
|
||||
// resize. Zoom composites the whole document at the requested factor
|
||||
// and is supported in all Chromium, WebKit, and modern Firefox (126+).
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/zoom
|
||||
// setProperty is used instead of root.style.zoom because `zoom` is not
|
||||
// in the standard CSSStyleDeclaration type.
|
||||
root.style.setProperty('zoom', scale)
|
||||
lastApplied.scale = scale
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2639,30 +2639,42 @@ export default {
|
||||
},
|
||||
font: {
|
||||
uiFont: 'Interface Font',
|
||||
uiFontDescription: 'Font used across the entire interface (sidebar, breadcrumbs, settings, etc.)',
|
||||
monoFont: 'Monospace Font',
|
||||
monoFontDescription: 'Font used for code blocks, API keys and technical identifiers',
|
||||
uiFontDescription: 'Font used for menus, body text, buttons, and most UI text',
|
||||
monoFont: 'Code Font',
|
||||
monoFontDescription: 'Used for code blocks, terminal commands, API keys, file paths and other technical text. Every character has the same width so you can tell 0 from O and 1 from l.',
|
||||
selectFont: 'Select font',
|
||||
sansPreview: 'The quick brown fox jumps — Aa Gg Oo 0123',
|
||||
monoPreview: "const msg = 'Hello'; // 0O1l",
|
||||
sans: {
|
||||
system: 'System Default',
|
||||
// macOS
|
||||
pingfang: 'PingFang SC',
|
||||
inter: 'Inter',
|
||||
helvetica: 'Helvetica / Arial',
|
||||
segoe: 'Segoe UI',
|
||||
roboto: 'Roboto',
|
||||
sansSerif: 'Generic Sans-Serif',
|
||||
georgia: 'Georgia (Serif)',
|
||||
// Windows
|
||||
yahei: 'Microsoft YaHei',
|
||||
times: 'Times New Roman (Serif)',
|
||||
// Linux
|
||||
'noto-cjk': 'Noto Sans CJK',
|
||||
'dejavu-serif': 'DejaVu Serif (Serif)',
|
||||
// cross-platform
|
||||
'sans-serif': 'Generic Sans-Serif',
|
||||
},
|
||||
mono: {
|
||||
system: 'System Default',
|
||||
cascadia: 'Cascadia Code',
|
||||
jetbrains: 'JetBrains Mono',
|
||||
fira: 'Fira Code',
|
||||
monaco: 'Monaco / Menlo',
|
||||
// macOS
|
||||
menlo: 'Menlo',
|
||||
monaco: 'Monaco',
|
||||
// Windows
|
||||
consolas: 'Consolas',
|
||||
cascadia: 'Cascadia Code',
|
||||
// Linux
|
||||
'dejavu-mono': 'DejaVu Sans Mono',
|
||||
'liberation-mono': 'Liberation Mono',
|
||||
// cross-platform
|
||||
monospace: 'Generic Monospace',
|
||||
},
|
||||
fontSize: 'Font Size',
|
||||
fontSizeDescription: 'Adjust the overall interface text size',
|
||||
fontSizeDescription: 'Scales the entire interface (text, icons, spacing) and applies immediately',
|
||||
size: {
|
||||
small: 'Small',
|
||||
normal: 'Normal',
|
||||
|
||||
@@ -1940,30 +1940,42 @@ export default {
|
||||
},
|
||||
font: {
|
||||
uiFont: "인터페이스 글꼴",
|
||||
uiFontDescription: "사이드바, 브레드크럼, 설정 등 인터페이스 전반에 사용되는 글꼴입니다",
|
||||
monoFont: "고정폭 글꼴",
|
||||
monoFontDescription: "코드 블록, API 키, 기술 식별자에 사용되는 글꼴입니다",
|
||||
uiFontDescription: "메뉴, 본문, 버튼 등 인터페이스 대부분의 텍스트에 사용되는 글꼴입니다",
|
||||
monoFont: "코드 글꼴",
|
||||
monoFontDescription: "코드 블록, 터미널 명령, API 키, 파일 경로 등 기술 텍스트에 사용됩니다. 모든 문자가 같은 너비로 표시되어 0과 O, 1과 l을 구분할 수 있습니다.",
|
||||
selectFont: "글꼴 선택",
|
||||
sansPreview: "샘플 Sample 글꼴 — Aa Gg Oo 0123",
|
||||
monoPreview: "const msg = 'Hello'; // 0O1l",
|
||||
sans: {
|
||||
system: "시스템 기본",
|
||||
// macOS
|
||||
pingfang: "PingFang SC",
|
||||
inter: "Inter",
|
||||
helvetica: "Helvetica / Arial",
|
||||
segoe: "Segoe UI",
|
||||
roboto: "Roboto",
|
||||
sansSerif: "일반 산세리프",
|
||||
georgia: "Georgia (세리프)",
|
||||
// Windows
|
||||
yahei: "Microsoft YaHei",
|
||||
times: "Times New Roman (세리프)",
|
||||
// Linux
|
||||
"noto-cjk": "Noto Sans CJK",
|
||||
"dejavu-serif": "DejaVu Serif (세리프)",
|
||||
// cross-platform
|
||||
"sans-serif": "일반 산세리프",
|
||||
},
|
||||
mono: {
|
||||
system: "시스템 기본",
|
||||
cascadia: "Cascadia Code",
|
||||
jetbrains: "JetBrains Mono",
|
||||
fira: "Fira Code",
|
||||
monaco: "Monaco / Menlo",
|
||||
// macOS
|
||||
menlo: "Menlo",
|
||||
monaco: "Monaco",
|
||||
// Windows
|
||||
consolas: "Consolas",
|
||||
cascadia: "Cascadia Code",
|
||||
// Linux
|
||||
"dejavu-mono": "DejaVu Sans Mono",
|
||||
"liberation-mono": "Liberation Mono",
|
||||
// cross-platform
|
||||
monospace: "일반 고정폭",
|
||||
},
|
||||
fontSize: "글꼴 크기",
|
||||
fontSizeDescription: "전체 인터페이스 텍스트 크기를 조정합니다",
|
||||
fontSizeDescription: "인터페이스 전체(텍스트, 아이콘, 간격)를 확대/축소하며 즉시 적용됩니다",
|
||||
size: {
|
||||
small: "작게",
|
||||
normal: "보통",
|
||||
|
||||
@@ -2446,30 +2446,42 @@ export default {
|
||||
},
|
||||
font: {
|
||||
uiFont: 'Шрифт интерфейса',
|
||||
uiFontDescription: 'Шрифт, используемый во всём интерфейсе (боковая панель, навигация, настройки и т. д.)',
|
||||
monoFont: 'Моноширинный шрифт',
|
||||
monoFontDescription: 'Шрифт для блоков кода, API-ключей и технических идентификаторов',
|
||||
uiFontDescription: 'Шрифт для меню, основного текста, кнопок и большинства элементов интерфейса',
|
||||
monoFont: 'Шрифт для кода',
|
||||
monoFontDescription: 'Используется для блоков кода, команд терминала, API-ключей, путей к файлам и других технических текстов. Все символы одной ширины, чтобы 0 не путался с O, а 1 — с l.',
|
||||
selectFont: 'Выбрать шрифт',
|
||||
sansPreview: 'Образец Sample Шрифт — Aa Gg Oo 0123',
|
||||
monoPreview: "const msg = 'Hello'; // 0O1l",
|
||||
sans: {
|
||||
system: 'Системный по умолчанию',
|
||||
// macOS
|
||||
pingfang: 'PingFang SC',
|
||||
inter: 'Inter',
|
||||
helvetica: 'Helvetica / Arial',
|
||||
segoe: 'Segoe UI',
|
||||
roboto: 'Roboto',
|
||||
sansSerif: 'Стандартный без засечек',
|
||||
georgia: 'Georgia (с засечками)',
|
||||
// Windows
|
||||
yahei: 'Microsoft YaHei',
|
||||
times: 'Times New Roman (с засечками)',
|
||||
// Linux
|
||||
'noto-cjk': 'Noto Sans CJK',
|
||||
'dejavu-serif': 'DejaVu Serif (с засечками)',
|
||||
// cross-platform
|
||||
'sans-serif': 'Стандартный без засечек',
|
||||
},
|
||||
mono: {
|
||||
system: 'Системный по умолчанию',
|
||||
cascadia: 'Cascadia Code',
|
||||
jetbrains: 'JetBrains Mono',
|
||||
fira: 'Fira Code',
|
||||
monaco: 'Monaco / Menlo',
|
||||
// macOS
|
||||
menlo: 'Menlo',
|
||||
monaco: 'Monaco',
|
||||
// Windows
|
||||
consolas: 'Consolas',
|
||||
cascadia: 'Cascadia Code',
|
||||
// Linux
|
||||
'dejavu-mono': 'DejaVu Sans Mono',
|
||||
'liberation-mono': 'Liberation Mono',
|
||||
// cross-platform
|
||||
monospace: 'Стандартный моноширинный',
|
||||
},
|
||||
fontSize: 'Размер шрифта',
|
||||
fontSizeDescription: 'Регулирует общий размер текста в интерфейсе',
|
||||
fontSizeDescription: 'Масштабирует весь интерфейс (текст, иконки, отступы) и применяется немедленно',
|
||||
size: {
|
||||
small: 'Маленький',
|
||||
normal: 'Обычный',
|
||||
|
||||
@@ -1918,30 +1918,42 @@ export default {
|
||||
},
|
||||
font: {
|
||||
uiFont: "界面字体",
|
||||
uiFontDescription: "应用于整个界面(侧边栏、面包屑、设置等)的字体",
|
||||
monoFont: "等宽字体",
|
||||
monoFontDescription: "用于代码块、API 密钥和技术标识符的字体",
|
||||
uiFontDescription: "用于菜单、正文、按钮等界面大部分文字的字体",
|
||||
monoFont: "代码字体",
|
||||
monoFontDescription: "用于代码块、终端命令、API 密钥、文件路径等技术内容,每个字符等宽显示,避免 0/O、1/l 混淆",
|
||||
selectFont: "选择字体",
|
||||
sansPreview: "示例 Sample 字体 Font — Aa Gg Oo 0123",
|
||||
monoPreview: "const msg = 'Hello'; // 0O1l",
|
||||
sans: {
|
||||
system: "系统默认",
|
||||
// macOS
|
||||
pingfang: "苹方 PingFang SC",
|
||||
inter: "Inter",
|
||||
helvetica: "Helvetica / Arial",
|
||||
segoe: "Segoe UI",
|
||||
roboto: "Roboto",
|
||||
sansSerif: "通用无衬线",
|
||||
georgia: "Georgia 衬线",
|
||||
// Windows
|
||||
yahei: "微软雅黑 Microsoft YaHei",
|
||||
times: "Times New Roman 衬线",
|
||||
// Linux
|
||||
"noto-cjk": "Noto Sans CJK",
|
||||
"dejavu-serif": "DejaVu Serif 衬线",
|
||||
// 跨平台
|
||||
"sans-serif": "通用无衬线",
|
||||
},
|
||||
mono: {
|
||||
system: "系统默认",
|
||||
cascadia: "Cascadia Code",
|
||||
jetbrains: "JetBrains Mono",
|
||||
fira: "Fira Code",
|
||||
monaco: "Monaco / Menlo",
|
||||
// macOS
|
||||
menlo: "Menlo",
|
||||
monaco: "Monaco",
|
||||
// Windows
|
||||
consolas: "Consolas",
|
||||
cascadia: "Cascadia Code",
|
||||
// Linux
|
||||
"dejavu-mono": "DejaVu Sans Mono",
|
||||
"liberation-mono": "Liberation Mono",
|
||||
// 跨平台
|
||||
monospace: "通用等宽",
|
||||
},
|
||||
fontSize: "字体大小",
|
||||
fontSizeDescription: "调整整体界面文字大小",
|
||||
fontSizeDescription: "整体缩放界面(文字、图标、间距等),切换后立即生效",
|
||||
size: {
|
||||
small: "小",
|
||||
normal: "正常",
|
||||
|
||||
@@ -962,7 +962,7 @@ defineExpose({
|
||||
<style scoped lang="less">
|
||||
.agent-list-container {
|
||||
margin: 0 16px 0 0;
|
||||
height: calc(100vh);
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
@@ -699,7 +699,7 @@ onMounted(async () => {
|
||||
.login-layout {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
min-height: 100%;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background: linear-gradient(225deg, #022c22 0%, #064e3b 15%, #065f46 25%, #047857 38%, #059669 50%, #07C05F 65%, #10B981 78%, #34D399 90%, #6EE7B7 100%);
|
||||
|
||||
@@ -1248,7 +1248,7 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
<style scoped lang="less">
|
||||
.kb-list-container {
|
||||
margin: 0 16px 0 0;
|
||||
height: calc(100vh);
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
@@ -65,7 +65,7 @@ const goToOrganizations = () => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.join-page {
|
||||
min-height: 100vh;
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@@ -1237,7 +1237,7 @@ onUnmounted(() => {
|
||||
<style scoped lang="less">
|
||||
.org-list-container {
|
||||
margin: 0 16px 0 0;
|
||||
height: calc(100vh);
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
@@ -162,7 +162,8 @@
|
||||
@blur="handleSystemPromptChange"
|
||||
@input="handlePromptInput"
|
||||
@keydown="handlePromptKeydown"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 13px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<PromptTemplateSelector
|
||||
type="agentSystemPrompt"
|
||||
@@ -220,7 +221,8 @@
|
||||
:autosize="{ minRows: 10, maxRows: 20 }"
|
||||
:placeholder="$t('conversationSettings.systemPrompt.placeholder')"
|
||||
@blur="handleSystemPromptNormalChange"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 13px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<PromptTemplateSelector
|
||||
type="systemPrompt"
|
||||
@@ -246,7 +248,8 @@
|
||||
:autosize="{ minRows: 15, maxRows: 30 }"
|
||||
:placeholder="$t('conversationSettings.contextTemplate.placeholder')"
|
||||
@blur="handleContextTemplateChange"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 13px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<PromptTemplateSelector
|
||||
type="contextTemplate"
|
||||
@@ -1749,6 +1752,16 @@ const handleConversationRerankModelChange = async (value: string) => {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// TDesign's <t-input>/<t-textarea> forwards `style=""` to its wrapper but
|
||||
// applies `font: var(--td-font-body-medium)` (a shorthand) to the inner
|
||||
// <input>/<textarea>, which silently resets font-family. Reach into those
|
||||
// elements explicitly so the code font takes effect for prompt editors.
|
||||
.mono-text-input :deep(input),
|
||||
.mono-text-input :deep(textarea) {
|
||||
font-family: var(--app-font-family-mono);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
.section-header {
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="api-key-control">
|
||||
<t-input
|
||||
v-model="displayApiKey"
|
||||
readonly
|
||||
<t-input
|
||||
v-model="displayApiKey"
|
||||
readonly
|
||||
type="text"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 12px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<t-button
|
||||
size="small"
|
||||
@@ -77,7 +78,8 @@
|
||||
:model-value="apiBaseUrlDisplay"
|
||||
readonly
|
||||
type="text"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 12px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<t-button
|
||||
size="small"
|
||||
@@ -136,7 +138,8 @@
|
||||
:model-value="wailsApiLanBaseURL"
|
||||
readonly
|
||||
type="text"
|
||||
style="width: 100%; font-family: var(--app-font-family-mono); font-size: 12px;"
|
||||
class="mono-text-input"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
<t-button
|
||||
size="small"
|
||||
@@ -571,6 +574,16 @@ onMounted(async () => {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// TDesign's <t-input> forwards `style=""` to its wrapper but applies
|
||||
// `font: var(--td-font-body-medium)` (a shorthand) to the real <input>
|
||||
// inside, which silently resets font-family. Reach into the inner input
|
||||
// explicitly so the code font actually takes effect for API keys, URLs,
|
||||
// etc. Scoped via `.mono-text-input` so this only applies where we opt in.
|
||||
.mono-text-input :deep(input) {
|
||||
font-family: var(--app-font-family-mono);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<label>{{ $t('font.uiFont') }}</label>
|
||||
<p class="desc">{{ $t('font.uiFontDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="setting-control setting-control--stacked">
|
||||
<t-select
|
||||
v-model="localSansFont"
|
||||
style="width: 280px;"
|
||||
@@ -69,16 +69,19 @@
|
||||
<span :style="{ fontFamily: opt.preview }">{{ opt.label }}</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<div class="font-preview" :style="{ fontFamily: currentSansStack }">
|
||||
{{ $t('font.sansPreview') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 等宽字体 -->
|
||||
<!-- 代码字体 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('font.monoFont') }}</label>
|
||||
<p class="desc">{{ $t('font.monoFontDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="setting-control setting-control--stacked">
|
||||
<t-select
|
||||
v-model="localMonoFont"
|
||||
style="width: 280px;"
|
||||
@@ -94,6 +97,9 @@
|
||||
<span :style="{ fontFamily: opt.preview }">{{ opt.label }}</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<div class="font-preview font-preview--mono" :style="{ fontFamily: currentMonoStack }">
|
||||
{{ $t('font.monoPreview') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -170,6 +176,8 @@ import {
|
||||
useFont,
|
||||
SANS_STACKS,
|
||||
MONO_STACKS,
|
||||
visibleSansKeys,
|
||||
visibleMonoKeys,
|
||||
type FontKey,
|
||||
type MonoFontKey,
|
||||
type FontSizeKey,
|
||||
@@ -201,25 +209,27 @@ watch(currentSans, (val) => { localSansFont.value = val })
|
||||
watch(currentMono, (val) => { localMonoFont.value = val })
|
||||
watch(currentSize, (val) => { localFontSize.value = val })
|
||||
|
||||
const sansFontOptions = computed<{ value: FontKey; label: string; preview: string }[]>(() => [
|
||||
{ value: 'system', label: t('font.sans.system'), preview: SANS_STACKS.system },
|
||||
{ value: 'pingfang', label: t('font.sans.pingfang'), preview: SANS_STACKS.pingfang },
|
||||
{ value: 'inter', label: t('font.sans.inter'), preview: SANS_STACKS.inter },
|
||||
{ value: 'helvetica', label: t('font.sans.helvetica'), preview: SANS_STACKS.helvetica },
|
||||
{ value: 'segoe', label: t('font.sans.segoe'), preview: SANS_STACKS.segoe },
|
||||
{ value: 'roboto', label: t('font.sans.roboto'), preview: SANS_STACKS.roboto },
|
||||
{ value: 'sans-serif', label: t('font.sans.sansSerif'), preview: SANS_STACKS['sans-serif'] },
|
||||
])
|
||||
const sansFontOptions = computed<{ value: FontKey; label: string; preview: string }[]>(() =>
|
||||
visibleSansKeys().map((key) => ({
|
||||
value: key,
|
||||
label: t(`font.sans.${key}`),
|
||||
preview: SANS_STACKS[key],
|
||||
})),
|
||||
)
|
||||
|
||||
const monoFontOptions = computed<{ value: MonoFontKey; label: string; preview: string }[]>(() => [
|
||||
{ value: 'system', label: t('font.mono.system'), preview: MONO_STACKS.system },
|
||||
{ value: 'cascadia', label: t('font.mono.cascadia'), preview: MONO_STACKS.cascadia },
|
||||
{ value: 'jetbrains', label: t('font.mono.jetbrains'), preview: MONO_STACKS.jetbrains },
|
||||
{ value: 'fira', label: t('font.mono.fira'), preview: MONO_STACKS.fira },
|
||||
{ value: 'monaco', label: t('font.mono.monaco'), preview: MONO_STACKS.monaco },
|
||||
{ value: 'consolas', label: t('font.mono.consolas'), preview: MONO_STACKS.consolas },
|
||||
{ value: 'monospace', label: t('font.mono.monospace'), preview: MONO_STACKS.monospace },
|
||||
])
|
||||
const monoFontOptions = computed<{ value: MonoFontKey; label: string; preview: string }[]>(() =>
|
||||
visibleMonoKeys().map((key) => ({
|
||||
value: key,
|
||||
label: t(`font.mono.${key}`),
|
||||
preview: MONO_STACKS[key],
|
||||
})),
|
||||
)
|
||||
|
||||
// Live preview stacks, driven by the local form refs so the preview row
|
||||
// updates immediately on selection — even before handleSansFontChange
|
||||
// commits the choice to the global store and writes the CSS variable.
|
||||
const currentSansStack = computed(() => SANS_STACKS[localSansFont.value] ?? SANS_STACKS.system)
|
||||
const currentMonoStack = computed(() => MONO_STACKS[localMonoFont.value] ?? MONO_STACKS.system)
|
||||
|
||||
// 系统信息
|
||||
const systemInfo = ref<any>(null)
|
||||
@@ -396,4 +406,33 @@ const handleFontSizeChange = (val: FontSizeKey) => {
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
// When a font picker is rendered, stack the select on top of a live
|
||||
// preview line so the user can verify their choice without hunting for
|
||||
// an API Info page or a code block.
|
||||
.setting-control--stacked {
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.font-preview {
|
||||
width: 280px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: var(--td-radius-medium);
|
||||
background: var(--td-bg-color-container);
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
box-sizing: border-box;
|
||||
|
||||
&--mono {
|
||||
// Harden the preview against wrap-around for long monospace samples.
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user