feat(frontend): add font size, namespace UI prefs per user

Build on the font picker with three additions per user feedback:

- Font size selector (Small / Normal / Large) wired through a new
  --app-font-scale CSS variable; the body font-size and every
  --td-font-size-* token are wrapped in calc(... * var(--app-font-scale))
  so TDesign components scale together with the body
- localStorage keys for theme, font family, mono font and font size are
  now namespaced as WeKnora_${userId}_${key}; falls back to "anon" before
  login. Each user keeps their own preferences in the same browser
- auth store calls reloadFontFromStorage / reloadThemeFromStorage on
  setUser (when the active user changes) and in logout, so a user switch
  swaps the applied preferences without a reload

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
This commit is contained in:
Claude
2026-05-02 08:21:37 +00:00
committed by lyingbug
parent f140c12518
commit bafcbd5e5f
10 changed files with 190 additions and 34 deletions
@@ -97,6 +97,25 @@
</div>
</div>
<!-- 字体大小 -->
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('font.fontSize') }}</label>
<p class="desc">{{ $t('font.fontSizeDescription') }}</p>
</div>
<div class="setting-control">
<t-radio-group
v-model="localFontSize"
variant="default-filled"
@change="handleFontSizeChange"
>
<t-radio-button value="small">{{ $t('font.size.small') }}</t-radio-button>
<t-radio-button value="normal">{{ $t('font.size.normal') }}</t-radio-button>
<t-radio-button value="large">{{ $t('font.size.large') }}</t-radio-button>
</t-radio-group>
</div>
</div>
<!-- 记忆功能开关 -->
<div class="setting-row">
<div class="setting-info">
@@ -154,19 +173,28 @@ import {
MONO_STACKS,
type FontKey,
type MonoFontKey,
type FontSizeKey,
} from '@/composables/useFont'
const { t, locale } = useI18n()
const settingsStore = useSettingsStore()
const authStore = useAuthStore()
const { currentTheme, setTheme } = useTheme()
const { currentSans, currentMono, setSansFont, setMonoFont } = useFont()
const {
currentSans,
currentMono,
currentSize,
setSansFont,
setMonoFont,
setFontSize,
} = useFont()
// 本地状态
const localLanguage = ref('zh-CN')
const localTheme = ref<ThemeMode>(currentTheme.value)
const localSansFont = ref<FontKey>(currentSans.value)
const localMonoFont = ref<MonoFontKey>(currentMono.value)
const localFontSize = ref<FontSizeKey>(currentSize.value)
const sansFontOptions = computed<{ value: FontKey; label: string; preview: string }[]>(() => [
{ value: 'system', label: t('font.sans.system'), preview: SANS_STACKS.system },
@@ -273,6 +301,11 @@ const handleMonoFontChange = (val: MonoFontKey) => {
setMonoFont(val)
MessagePlugin.success(t('common.success'))
}
const handleFontSizeChange = (val: FontSizeKey) => {
setFontSize(val)
MessagePlugin.success(t('common.success'))
}
</script>
<style lang="less" scoped>