From d69061223395374e7c8dc2f6c5cdaca0e245be6f Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Thu, 11 Sep 2025 18:15:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(unocss):=20=E6=B7=BB=E5=8A=A0legacy?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=A2=84=E8=AE=BE=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BD=8E=E7=AB=AF=E5=AE=89=E5=8D=93=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加presetLegacyCompat预设以解决低端安卓机的样式兼容性问题,将颜色函数从空格分隔转换为逗号分隔格式 --- uno.config.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/uno.config.ts b/uno.config.ts index bd647bf..01e6728 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -1,5 +1,11 @@ +import type { + Preset, +} from 'unocss' // https://www.npmjs.com/package/@uni-helper/unocss-preset-uni import { presetUni } from '@uni-helper/unocss-preset-uni' + +// @see https://unocss.dev/presets/legacy-compat +import { presetLegacyCompat } from '@unocss/preset-legacy-compat' import { defineConfig, presetAttributify, @@ -23,6 +29,14 @@ export default defineConfig({ }), // 支持css class属性化 presetAttributify(), + // TODO: check 是否会有别的影响 + // 处理低端安卓机的样式问题 + // 将颜色函数 (rgb()和hsl()) 从空格分隔转换为逗号分隔,更好的兼容性app端,example: + // `rgb(255 0 0)` -> `rgb(255, 0, 0)` + // `rgba(255 0 0 / 0.5)` -> `rgba(255, 0, 0, 0.5)` + presetLegacyCompat({ + commaStyleColorFunction: true, + }) as Preset, ], transformers: [ // 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令