3 Star 88 Fork 4

Fantastic-mobile/basic

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
uno.config.ts 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
Hooray 提交于 2024-09-21 04:31 . chore: 更新依赖
import type { Theme } from 'unocss/preset-uno'
import { entriesToCss, toArray } from '@unocss/core'
import presetRemToPx from '@unocss/preset-rem-to-px'
import presetSafeArea from '@yeungkc/unocss-preset-safe-area'
import {
defineConfig,
presetAttributify,
presetIcons,
presetTypography,
presetUno,
transformerCompileClass,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
import { darkTheme, lightTheme } from './themes'
export default defineConfig<Theme>({
content: {
pipeline: {
include: [
/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
'src/**/*.{js,ts}',
],
},
},
variants: [
(matcher) => {
if (!matcher.startsWith('hocus:') && !matcher.startsWith('hocus-')) {
return matcher
}
return {
matcher: matcher.slice(6),
selector: s => `${s}:hover, ${s}:focus`,
}
},
],
shortcuts: [
[/^flex-?(col)?-(start|end|center|baseline|stretch)-?(start|end|center|between|around|evenly|left|right)?$/, ([, col, items, justify]) => {
const cls = ['flex']
if (col === 'col') {
cls.push('flex-col')
}
if (items === 'center' && !justify) {
cls.push('items-center')
cls.push('justify-center')
}
else {
cls.push(`items-${items}`)
if (justify) {
cls.push(`justify-${justify}`)
}
}
return cls.join(' ')
}],
],
preflights: [
{
getCSS: () => {
const returnCss: any = []
// 明亮主题
const lightCss = entriesToCss(Object.entries(lightTheme))
const lightRoots = toArray([`*,::before,::after`, `::backdrop`])
returnCss.push(lightRoots.map(root => `${root}{${lightCss}}`).join(''))
// 暗黑主题
const darkCss = entriesToCss(Object.entries(darkTheme))
const darkRoots = toArray([`html.dark,html.dark *,html.dark ::before,html.dark ::after`, `html.dark ::backdrop`])
returnCss.push(darkRoots.map(root => `${root}{${darkCss}}`).join(''))
return returnCss.join('')
},
},
],
theme: {
colors: {
'ui-primary': 'rgb(var(--ui-primary))',
'ui-text': 'rgb(var(--ui-text))',
},
},
presets: [
presetUno(),
presetAttributify(),
presetIcons({
extraProperties: {
'display': 'inline-block',
'vertical-align': 'middle',
},
}),
presetTypography(),
presetRemToPx(),
presetSafeArea(),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
transformerCompileClass(),
],
configDeps: [
'themes/index.ts',
],
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/fantastic-mobile/basic.git
git@gitee.com:fantastic-mobile/basic.git
fantastic-mobile
basic
basic
main

搜索帮助