icssoa 7 месяцев назад
Родитель
Сommit
8d35b3b096
2 измененных файлов с 7 добавлено и 8 удалено
  1. 1 2
      components/size-set.uvue
  2. 6 6
      uni_modules/cool-ui/hooks/size.ts

+ 1 - 2
components/size-set.uvue

@@ -11,7 +11,7 @@
 			<view class="px-3 absolute top-0 left-0 z-10">
 				<cl-text
 					:style="{
-						fontSize: px2rpx(14) * size + 'rpx'
+						fontSize: 28 * size + 'rpx'
 					}"
 					>{{ t("这是一段示例文字,用于预览不同字号的效果。") }}</cl-text
 				>
@@ -21,7 +21,6 @@
 </template>
 
 <script setup lang="ts">
-import { px2rpx } from "@/cool";
 import { t } from "@/locale";
 import { type ClSelectOption } from "@/uni_modules/cool-ui";
 import { config } from "@/uni_modules/cool-ui/config";

+ 6 - 6
uni_modules/cool-ui/hooks/size.ts

@@ -24,11 +24,11 @@ class Size {
 		"text-9xl"
 	];
 
-	// 对应的字号大小(px)
-	public sizes = [10, 12, 14, 16, 18, 22, 28, 34, 46, 58, 70, 94, 126];
+	// 对应的字号大小
+	public sizes = [20, 24, 28, 32, 36, 44, 52, 60, 72, 84, 96, 120, 152];
 
-	// 对应的行高(px)
-	public lineHeights = [14, 18, 22, 26, 26, 1, 1, 1, 1, 1, 1, 1, 1];
+	// 对应的行高
+	public lineHeights = [28, 36, 44, 52, 52, 1, 1, 1, 1, 1, 1, 1, 1];
 
 	// 原始类名
 	public className: ComputedRef<string> = computed(() => "");
@@ -104,7 +104,7 @@ class Size {
 			return null;
 		}
 
-		return this.getRpx(size ?? px2rpx(this.sizes[this.getIndex()]));
+		return this.getRpx(size ?? this.sizes[this.getIndex()]);
 	};
 
 	/**
@@ -117,7 +117,7 @@ class Size {
 		}
 
 		const lineHeight = this.lineHeights[this.getIndex()];
-		return lineHeight == 1 ? `1` : this.getRpx(px2rpx(lineHeight));
+		return lineHeight == 1 ? `1` : this.getRpx(lineHeight);
 	};
 }