46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
/*
|
|
* @Author: 田鑫
|
|
* @Date: 2023-03-05 18:14:16
|
|
* @LastEditors: rd 1344903914@qq.com
|
|
* @LastEditTime: 2025-07-11 16:30:29
|
|
* @Description:
|
|
*/
|
|
import Unocss from 'unocss/vite';
|
|
import {
|
|
presetUno,
|
|
presetIcons,
|
|
presetAttributify,
|
|
transformerDirectives,
|
|
transformerCompileClass,
|
|
transformerVariantGroup,
|
|
transformerAttributifyJsx,
|
|
} from 'unocss';
|
|
import presetRemToPx from '@unocss/preset-rem-to-px';
|
|
|
|
export const configUnocss = () =>
|
|
Unocss({
|
|
presets: [presetUno(), presetIcons(), presetAttributify(), presetRemToPx()],
|
|
transformers: [
|
|
transformerDirectives(),
|
|
transformerCompileClass(),
|
|
transformerVariantGroup(),
|
|
transformerAttributifyJsx(),
|
|
],
|
|
shortcuts: [
|
|
// 垂直水平居中
|
|
['flex-center', 'flex justify-center items-center'],
|
|
],
|
|
rules: [
|
|
[/^mgl-(\d+)$/, ([, d]) => ({ 'margin-left': `${d}px !important` })],
|
|
[/^mgr-(\d+)$/, ([, d]) => ({ 'margin-right': `${d}px !important` })],
|
|
[/^mgt-(\d+)$/, ([, d]) => ({ 'margin-top': `${d}px !important` })],
|
|
[/^mgb-(\d+)$/, ([, d]) => ({ 'margin-bottom': `${d}px !important` })],
|
|
[/^pd-(\d+)$/, ([, d]) => ({ padding: `${d}px !important` })],
|
|
[/^flex-(\d+)$/, ([, d]) => ({ flex: `${d} !important` })],
|
|
[/^w(\d+)$/, ([, d]) => ({ width: `${d}% !important` })],
|
|
[/^w-(\d+)$/, ([, d]) => ({ width: `${d}px !important` })],
|
|
[/^h-(\d+)$/, ([, d]) => ({ height: `${d}px !important` })],
|
|
[/^ft-(\d+)$/, ([, d]) => ({ 'font-size': `${d}px !important` })],
|
|
],
|
|
});
|