feat: 添加@unocss/preset-legacy-compat解决app rgba问题

This commit is contained in:
菲鸽 2024-04-12 14:58:44 +08:00
parent 981eb1d096
commit 39614e4284
3 changed files with 23 additions and 0 deletions

View File

@ -117,6 +117,7 @@
"@uni-helper/vite-plugin-uni-manifest": "^0.2.3", "@uni-helper/vite-plugin-uni-manifest": "^0.2.3",
"@uni-helper/vite-plugin-uni-pages": "^0.2.15", "@uni-helper/vite-plugin-uni-pages": "^0.2.15",
"@uni-helper/vite-plugin-uni-platform": "^0.0.4", "@uni-helper/vite-plugin-uni-platform": "^0.0.4",
"@unocss/preset-legacy-compat": "^0.59.1",
"@vue/runtime-core": "^3.3.13", "@vue/runtime-core": "^3.3.13",
"@vue/tsconfig": "^0.1.3", "@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.16", "autoprefixer": "^10.4.16",

13
pnpm-lock.yaml generated
View File

@ -121,6 +121,9 @@ devDependencies:
'@uni-helper/vite-plugin-uni-platform': '@uni-helper/vite-plugin-uni-platform':
specifier: ^0.0.4 specifier: ^0.0.4
version: 0.0.4 version: 0.0.4
'@unocss/preset-legacy-compat':
specifier: ^0.59.1
version: 0.59.1
'@vue/runtime-core': '@vue/runtime-core':
specifier: ^3.3.13 specifier: ^3.3.13
version: 3.3.13 version: 3.3.13
@ -4301,6 +4304,10 @@ packages:
resolution: {integrity: sha512-KhABQXGE2AgtO9vE28d+HnciuyGDcuygsnQdUwlzUuR4K05OSw2kRE9emRN4HaMycD+gA/zDbQrJxTXb6mQUiA==} resolution: {integrity: sha512-KhABQXGE2AgtO9vE28d+HnciuyGDcuygsnQdUwlzUuR4K05OSw2kRE9emRN4HaMycD+gA/zDbQrJxTXb6mQUiA==}
dev: true dev: true
/@unocss/core@0.59.1:
resolution: {integrity: sha512-4T9eSmEhmxlYnz0xilIavROiEWvEcEtWixIQEaP4MqWabaRew6yN1ky4ALZZgaTUdS50EXGR3bYVz1vah9sfFw==}
dev: true
/@unocss/extractor-arbitrary-variants@0.56.5: /@unocss/extractor-arbitrary-variants@0.56.5:
resolution: {integrity: sha512-p2pyzz/ONvc5CGcaB9OZvWE8qkRSgyuhaQqFQLdBFeUhveHC0CGP0iSnXwBgAFHWM7DJo4/JpWeZ+mBt0ogVLA==} resolution: {integrity: sha512-p2pyzz/ONvc5CGcaB9OZvWE8qkRSgyuhaQqFQLdBFeUhveHC0CGP0iSnXwBgAFHWM7DJo4/JpWeZ+mBt0ogVLA==}
dependencies: dependencies:
@ -4353,6 +4360,12 @@ packages:
- supports-color - supports-color
dev: true dev: true
/@unocss/preset-legacy-compat@0.59.1:
resolution: {integrity: sha512-aqz+KehvubXYMoKmlMHPI79OZ1RkVQrr1v5pDlnGrRWSWY/JNdNa44Bw6cO/g8yEucf/nNe/1YqLf7jJ9tL8og==}
dependencies:
'@unocss/core': 0.59.1
dev: true
/@unocss/preset-mini@0.56.5: /@unocss/preset-mini@0.56.5:
resolution: {integrity: sha512-/KhlThhs1ilauM7MwRSpahLbIPZ5VGeGvaUsU8+ZlNT3sis4yoVYkPtR14tL2IT6jhOU05N/uu3aBj+1bP8GjQ==} resolution: {integrity: sha512-/KhlThhs1ilauM7MwRSpahLbIPZ5VGeGvaUsU8+ZlNT3sis4yoVYkPtR14tL2IT6jhOU05N/uu3aBj+1bP8GjQ==}
dependencies: dependencies:

View File

@ -15,6 +15,9 @@ import {
transformerAttributify, transformerAttributify,
} from 'unocss-applet' } from 'unocss-applet'
// @see https://unocss.dev/presets/legacy-compat
import presetLegacyCompat from '@unocss/preset-legacy-compat'
const isH5 = process.env?.UNI_PLATFORM === 'h5' const isH5 = process.env?.UNI_PLATFORM === 'h5'
const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
@ -44,6 +47,12 @@ export default defineConfig({
'vertical-align': 'middle', 'vertical-align': 'middle',
}, },
}), }),
// 将颜色函数 (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,
], ],
/** /**
* *