Browse Source

fix: 修复字体缩放存储问题并优化样式

修复utils/index.js中字体缩放存储的键名错误问题
移除App.vue中重复的字体缩放逻辑
在uni.scss中添加全局小字体样式提醒
master
wei 5 days ago
parent
commit
44d7a4566c
  1. 3
      App.vue
  2. 2
      libs/utils/index.js
  3. 4
      uni.scss

3
App.vue

@ -1,5 +1,4 @@
<script>
import { increaseFontScale } from "@/libs/utils/index.js";
import useStore from "@/store";
export default {
@ -7,7 +6,6 @@ export default {
// console.log("App Launch");
const store = useStore();
store.fontScale = uni.getStorageSync("fontScale") || 1;
increaseFontScale(store.fontScale - 1);
},
onShow() {
// console.log("App Show");
@ -15,7 +13,6 @@ export default {
onHide() {
const store = useStore();
uni.setStorageSync("fontScale", store.fontScale);
// console.log("App Hide");
},
};
</script>

2
libs/utils/index.js

@ -188,5 +188,5 @@ export function validates(validators, toastConfig = { icon: "none", returnBoolea
export function increaseFontScale(incScale = 0.1) {
const store = useStore();
store.fontScale += incScale;
uni.setStorageSync(store.fontScale);
uni.setStorageSync("fontScale", store.fontScale);
}

4
uni.scss

@ -42,6 +42,10 @@ $uni-border-color:#c8c7cc;
// --font-scale: 1
// }
* {
font-size: $text-xs; // 设置小字体时刻提醒要写标准字体
}
/* 文字尺寸 */
$uni-font-size-sm: calc(var(--font-scale, 1) * 12px);
$uni-font-size-base: calc(var(--font-scale, 1) * 14px);

Loading…
Cancel
Save