Skip to content

Commit d690612

Browse files
author
feige996
committed
feat(unocss): 添加legacy兼容预设以支持低端安卓机
添加presetLegacyCompat预设以解决低端安卓机的样式兼容性问题,将颜色函数从空格分隔转换为逗号分隔格式
1 parent c870229 commit d690612

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

uno.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import type {
2+
Preset,
3+
} from 'unocss'
14
// https://www.npmjs.com/package/@uni-helper/unocss-preset-uni
25
import { presetUni } from '@uni-helper/unocss-preset-uni'
6+
7+
// @see https://unocss.dev/presets/legacy-compat
8+
import { presetLegacyCompat } from '@unocss/preset-legacy-compat'
39
import {
410
defineConfig,
511
presetAttributify,
@@ -23,6 +29,14 @@ export default defineConfig({
2329
}),
2430
// 支持css class属性化
2531
presetAttributify(),
32+
// TODO: check 是否会有别的影响
33+
// 处理低端安卓机的样式问题
34+
// 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example:
35+
// `rgb(255 0 0)` -> `rgb(255, 0, 0)`
36+
// `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)`
37+
presetLegacyCompat({
38+
commaStyleColorFunction: true,
39+
}) as Preset,
2640
],
2741
transformers: [
2842
// 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令

0 commit comments

Comments
 (0)