兼容 ios

This commit is contained in:
icssoa
2025-09-04 20:18:18 +08:00
parent 083c8b1325
commit f01d1107b9
15 changed files with 316 additions and 146 deletions

View File

@@ -1,5 +1,6 @@
import { computed, type ComputedRef } from "vue";
import { config } from "../config";
import { rpx2px } from "@/cool";
/**
* 字号管理类
@@ -73,6 +74,35 @@ class Size {
}
};
/**
* 获取px值
* @param val - 需要转换的值 10、10rpx、10px
* @returns 转换后的px值
*/
getPxValue = (val: number | string) => {
const scale = this.getScale();
if (typeof val == "string") {
const num = parseFloat(val);
const unit = val.replace(`${num}`, "");
if (unit == "px") {
return num * scale;
} else {
return rpx2px(num * scale);
}
} else {
return rpx2px(val * scale);
}
};
/**
* 获取px值
*/
getPx = (val: number | string) => {
return this.getPxValue(val) + "px";
};
/**
* 获取当前字号在预设中的索引
*/