export function readSystemFontScale() { try { if (typeof uni !== 'undefined' && uni.getAppBaseInfo) { const baseInfo = uni.getAppBaseInfo() if (baseInfo && typeof baseInfo.fontSizeScaleFactor === 'number' && !isNaN(baseInfo.fontSizeScaleFactor)) { return baseInfo.fontSizeScaleFactor } if (baseInfo && typeof baseInfo.fontSizeSetting === 'number' && !isNaN(baseInfo.fontSizeSetting)) { const scale = baseInfo.fontSizeSetting / 16 if (scale > 0) { return scale } } } } catch (e) { // ignore } try { if (typeof wx !== 'undefined' && wx.getAppBaseInfo) { const baseInfo = wx.getAppBaseInfo() if (baseInfo && typeof baseInfo.fontSizeScaleFactor === 'number' && !isNaN(baseInfo.fontSizeScaleFactor)) { return baseInfo.fontSizeScaleFactor } if (baseInfo && typeof baseInfo.fontSizeSetting === 'number' && !isNaN(baseInfo.fontSizeSetting)) { const scale = baseInfo.fontSizeSetting / 16 if (scale > 0) { return scale } } } } catch (e) { // ignore } return 1 } export function getFontScale() { try { const stored = uni.getStorageSync('fontSizeScaleFactor') if (typeof stored === 'number' && !isNaN(stored) && stored > 0) { let scale = stored if (scale < 0.9) scale = 0.9 if (scale > 1.7) scale = 1.7 const rounded = Math.round(scale * 100) / 100 return rounded } } catch (e) { // ignore } const systemScale = readSystemFontScale() let scale = systemScale if (isNaN(scale) || scale <= 0) { scale = 1 } if (scale < 0.9) scale = 0.9 if (scale > 1.7) scale = 1.7 const rounded = Math.round(scale * 100) / 100 return rounded } export function syncFontScale() { const systemScale = readSystemFontScale() let scale = systemScale if (isNaN(scale) || scale <= 0) { scale = 1 } if (scale < 0.9) scale = 0.9 if (scale > 1.7) scale = 1.7 const rounded = Math.round(scale * 100) / 100 try { uni.setStorageSync('fontSizeScaleFactor', rounded) } catch (e) { // ignore } return rounded }