export type AppFontSize = 'standard' | 'large' | 'extra-large'; export const appFontSizeKey = 'aihr_mobile_font_size'; export const appFontSizeOptions: Array<{ value: AppFontSize; label: string }> = [ { value: 'standard', label: '标准' }, { value: 'large', label: '大字' }, { value: 'extra-large', label: '超大字' } ]; const normalizeAppFontSize = (value: unknown): AppFontSize => { if (value === 'large' || value === 'extra-large') return value; return 'standard'; }; export const getAppFontSize = (): AppFontSize => normalizeAppFontSize(uni.getStorageSync(appFontSizeKey)); export const applyAppFontSize = (value: AppFontSize) => { if (typeof document === 'undefined') return; document.documentElement.setAttribute('data-aihr-font-size', value); }; export const setAppFontSize = (value: AppFontSize) => { const normalized = normalizeAppFontSize(value); uni.setStorageSync(appFontSizeKey, normalized); applyAppFontSize(normalized); return normalized; }; export const applyStoredFontSize = () => applyAppFontSize(getAppFontSize());