feat(frontend): unify font rendering and add font picker in settings

The UI used hardcoded "PingFang SC" in 50+ components, while the global
font stack in App.vue used a different fallback chain. Outside of mainland
China this caused visibly different fonts in the sidebar, breadcrumbs,
search and agent views compared to settings and document panes.

- Introduce --app-font-family / --app-font-family-mono CSS variables in
  theme.css and route TDesign's --td-font-family through them
- Add a useFont composable that persists the user's choice in localStorage
  and applies it via document.documentElement.style before mount
- Replace hardcoded font-family declarations across the app with the new
  variables (TencentSans logo and the SVG attribute list are preserved)
- Add UI font and monospace font selectors in General Settings with
  i18n strings for en-US, zh-CN, ko-KR and ru-RU

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
This commit is contained in:
Claude
2026-05-02 08:06:56 +00:00
committed by lyingbug
parent 6c1442aaf9
commit f140c12518
59 changed files with 542 additions and 251 deletions
@@ -340,7 +340,7 @@ const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: Know
height: 40px;
font-size: 12px;
font-weight: 500;
font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
font-family: var(--app-font-family);
color: var(--td-text-color-secondary);
background: var(--td-bg-color-secondarycontainer);
border-bottom: 1px solid var(--td-component-stroke);
@@ -402,7 +402,7 @@ const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: Know
.cell-name {
gap: 10px;
font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
font-family: var(--app-font-family);
}
.cell-size,
@@ -481,7 +481,7 @@ const handleAction = (action: 'edit' | 'reparse' | 'move' | 'delete', item: Know
.row-mono {
font-variant-numeric: tabular-nums;
font-size: 12px;
font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif;
font-family: var(--app-font-family);
color: var(--td-text-color-secondary);
}
@@ -3459,7 +3459,7 @@ watch(() => entries.value.map(e => ({
color: var(--td-text-color-primary);
cursor: pointer;
transition: all 0.2s ease;
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
font-family: var(--app-font-family);
font-size: 13px;
-webkit-font-smoothing: antialiased;
@@ -3482,7 +3482,7 @@ watch(() => entries.value.map(e => ({
}
.tag-hash-icon {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-family: var(--app-font-family-mono);
font-size: 16px;
font-weight: 500;
width: 16px;
@@ -3497,7 +3497,7 @@ watch(() => entries.value.map(e => ({
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
font-family: var(--app-font-family);
font-size: 13px;
font-weight: 400;
line-height: 1.4;
@@ -3758,7 +3758,7 @@ watch(() => entries.value.map(e => ({
cursor: pointer;
transition: all 0.2s ease;
color: var(--td-text-color-primary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 400;
@@ -3896,7 +3896,7 @@ watch(() => entries.value.map(e => ({
h2 {
margin: 0;
color: var(--td-text-color-primary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 24px;
font-weight: 600;
line-height: 32px;
@@ -3905,7 +3905,7 @@ watch(() => entries.value.map(e => ({
.faq-subtitle {
margin: 0;
color: var(--td-text-color-placeholder);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 400;
line-height: 20px;
@@ -4062,7 +4062,7 @@ watch(() => entries.value.map(e => ({
}
.result-title {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-weight: 600;
font-size: 14px;
color: var(--td-text-color-primary);
@@ -4075,7 +4075,7 @@ watch(() => entries.value.map(e => ({
gap: 12px;
.result-time {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 13px;
color: var(--td-text-color-secondary);
}
@@ -4112,7 +4112,7 @@ watch(() => entries.value.map(e => ({
display: flex;
align-items: center;
gap: 6px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 13px;
.stat-label {
@@ -4359,7 +4359,7 @@ watch(() => entries.value.map(e => ({
border: 1px solid var(--td-component-stroke);
font-size: 11px;
color: var(--td-text-color-secondary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
.status-icon {
font-size: 13px;
@@ -4428,7 +4428,7 @@ watch(() => entries.value.map(e => ({
background: var(--td-bg-color-container-hover);
font-size: 11px;
font-weight: 400;
font-family: "PingFang SC";
font-family: var(--app-font-family);
transition: all 0.2s ease;
&:hover {
@@ -4486,7 +4486,7 @@ watch(() => entries.value.map(e => ({
.faq-question {
flex: 1;
color: var(--td-text-color-primary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 15px;
font-weight: 600;
line-height: 1.5;
@@ -4518,7 +4518,7 @@ watch(() => entries.value.map(e => ({
.faq-section-label {
color: var(--td-text-color-secondary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
@@ -4609,7 +4609,7 @@ watch(() => entries.value.map(e => ({
max-width: 100%;
min-width: 0;
border-radius: 5px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
flex: 0 1 auto;
:deep(.t-tag) {
@@ -4658,7 +4658,7 @@ watch(() => entries.value.map(e => ({
font-size: 12px;
font-style: italic;
padding: 8px 0;
font-family: "PingFang SC";
font-family: var(--app-font-family);
}
@@ -4670,7 +4670,7 @@ watch(() => entries.value.map(e => ({
padding: 24px 16px;
color: var(--td-text-color-secondary);
font-size: 13px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
}
.faq-no-more {
@@ -4702,7 +4702,7 @@ watch(() => entries.value.map(e => ({
.empty-text {
color: var(--td-text-color-primary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 18px;
font-weight: 600;
line-height: 28px;
@@ -4710,7 +4710,7 @@ watch(() => entries.value.map(e => ({
.empty-desc {
color: var(--td-text-color-secondary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 400;
line-height: 22px;
@@ -4780,7 +4780,7 @@ watch(() => entries.value.map(e => ({
.import-title {
margin: 0;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 18px;
font-weight: 600;
color: var(--td-text-color-primary);
@@ -4848,7 +4848,7 @@ watch(() => entries.value.map(e => ({
display: flex;
align-items: center;
gap: 6px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 13px;
font-weight: 500;
padding: 6px 14px;
@@ -4879,7 +4879,7 @@ watch(() => entries.value.map(e => ({
.import-form-label {
display: block;
margin-bottom: 0;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
color: var(--td-text-color-primary);
@@ -4903,7 +4903,7 @@ watch(() => entries.value.map(e => ({
}
.t-radio-button {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
border-color: var(--td-component-stroke);
transition: all 0.2s ease;
@@ -4994,20 +4994,20 @@ watch(() => entries.value.map(e => ({
}
.upload-primary-text {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
color: var(--td-text-color-primary);
}
.upload-secondary-text {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 12px;
color: var(--td-text-color-secondary);
}
.upload-file-name {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
color: var(--td-brand-color);
@@ -5017,7 +5017,7 @@ watch(() => entries.value.map(e => ({
// 导入表单提示
.import-form-tip {
margin-top: 8px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 12px;
color: var(--td-text-color-disabled);
line-height: 18px;
@@ -5047,7 +5047,7 @@ watch(() => entries.value.map(e => ({
}
.preview-title {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
color: var(--td-text-color-primary);
@@ -5086,14 +5086,14 @@ watch(() => entries.value.map(e => ({
background: linear-gradient(135deg, var(--td-brand-color) 0%, var(--td-brand-color-active) 100%);
color: var(--td-text-color-anti);
border-radius: 4px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 12px;
font-weight: 600;
}
.preview-question {
flex: 1;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 13px;
color: var(--td-text-color-primary);
line-height: 1.5;
@@ -5104,7 +5104,7 @@ watch(() => entries.value.map(e => ({
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--td-component-stroke);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 12px;
color: var(--td-text-color-secondary);
text-align: center;
@@ -5127,7 +5127,7 @@ watch(() => entries.value.map(e => ({
.t-drawer__header {
padding: 20px 24px;
border-bottom: 1px solid var(--td-component-stroke);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 18px;
font-weight: 600;
color: var(--td-text-color-primary);
@@ -5208,7 +5208,7 @@ watch(() => entries.value.map(e => ({
height: 32px;
min-width: 32px;
padding: 0;
font-family: "PingFang SC";
font-family: var(--app-font-family);
transition: all 0.2s ease;
border-radius: 8px;
}
@@ -5259,7 +5259,7 @@ watch(() => entries.value.map(e => ({
.item-count {
font-size: 13px;
color: var(--td-text-color-secondary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-weight: 500;
text-align: right;
padding-right: 40px;
@@ -5315,7 +5315,7 @@ watch(() => entries.value.map(e => ({
font-size: 14px;
line-height: 1.6;
color: var(--td-text-color-primary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
white-space: pre-wrap;
word-break: break-word;
padding: 0;
@@ -5361,7 +5361,7 @@ watch(() => entries.value.map(e => ({
margin-top: 6px;
font-size: 12px;
color: var(--td-text-color-disabled);
font-family: "PingFang SC";
font-family: var(--app-font-family);
}
// FAQ编辑器表单样式 - 完全参考设置页面
@@ -5586,7 +5586,7 @@ watch(() => entries.value.map(e => ({
// Input 组件样式 - 与登录页面一致
:deep(.t-input) {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
border: 1px solid var(--td-component-stroke);
border-radius: 8px;
@@ -5608,7 +5608,7 @@ watch(() => entries.value.map(e => ({
outline: none !important;
background: transparent;
font-size: 14px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
padding: 6px 12px;
color: var(--td-text-color-primary);
@@ -5631,7 +5631,7 @@ watch(() => entries.value.map(e => ({
// Textarea 组件样式
:deep(.t-textarea) {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
border: 1px solid var(--td-component-stroke);
border-radius: 8px;
@@ -5653,7 +5653,7 @@ watch(() => entries.value.map(e => ({
outline: none !important;
background: transparent;
font-size: 14px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
line-height: 1.6;
resize: vertical;
padding: 6px 12px;
@@ -5732,7 +5732,7 @@ watch(() => entries.value.map(e => ({
.t-drawer__header {
padding: 20px 24px;
border-bottom: 1px solid var(--td-component-stroke);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 18px;
font-weight: 600;
color: var(--td-text-color-primary);
@@ -5871,7 +5871,7 @@ watch(() => entries.value.map(e => ({
flex-shrink: 0;
min-width: 50px;
text-align: right;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
color: var(--td-text-color-primary);
@@ -5883,7 +5883,7 @@ watch(() => entries.value.map(e => ({
.search-button {
height: 36px;
border-radius: 8px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
@@ -5915,7 +5915,7 @@ watch(() => entries.value.map(e => ({
margin-left: 0;
margin-right: 0;
padding-left: 0;
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 600;
color: var(--td-text-color-primary);
@@ -5933,7 +5933,7 @@ watch(() => entries.value.map(e => ({
justify-content: center;
padding: 48px 16px;
color: var(--td-text-color-secondary);
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
text-align: center;
background: var(--td-bg-color-container);
@@ -6010,7 +6010,7 @@ watch(() => entries.value.map(e => ({
}
.result-question {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 14px;
font-weight: 600;
color: var(--td-text-color-primary);
@@ -6075,7 +6075,7 @@ watch(() => entries.value.map(e => ({
font-size: 12px;
padding: 4px 8px;
border-radius: 6px;
font-family: "PingFang SC";
font-family: var(--app-font-family);
}
.result-body {
@@ -6258,7 +6258,7 @@ watch(() => entries.value.map(e => ({
}
.section-label {
font-family: "PingFang SC";
font-family: var(--app-font-family);
font-size: 12px;
font-weight: 600;
color: var(--td-text-color-secondary);