fix(web): improve font scale compatibility and defaults

This commit is contained in:
weishu
2026-01-29 16:33:30 +08:00
parent efbe4f8d90
commit 308249abdb
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -20,6 +20,8 @@ function isBrowser(): boolean {
return typeof window !== 'undefined' && typeof document !== 'undefined'
}
const useIsomorphicLayoutEffect = isBrowser() ? useLayoutEffect : useEffect
function safeGetItem(key: string): string | null {
if (!isBrowser()) {
return null
@@ -79,7 +81,7 @@ export function initializeFontScale(): void {
export function useFontScale(): { fontScale: FontScale; setFontScale: (scale: FontScale) => void } {
const [fontScale, setFontScaleState] = useState<FontScale>(getInitialFontScale)
useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
applyFontScale(fontScale)
}, [fontScale])
+2 -1
View File
@@ -90,7 +90,7 @@
}
html {
font-size: calc(100% * var(--app-font-scale));
font-size: calc(100% * var(--app-font-scale, 1));
}
html,
@@ -105,6 +105,7 @@ body {
}
body {
font-size: 1rem;
background: var(--app-bg);
color: var(--app-fg);
}