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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user