Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
1c81c18d
提交
1c81c18d
authored
3月 19, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 实验性添加 unocss icon
上级
bae26471
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
83 行增加
和
8 行删除
+83
-8
unocss.ts
build/vite/unocss.ts
+11
-1
index.vue
src/components/Icon/index.vue
+31
-0
index.vue
src/pages/index/index.vue
+17
-4
components.d.ts
types/components.d.ts
+0
-0
unocss.config.ts
unocss.config.ts
+24
-3
没有找到文件。
build/vite/unocss.ts
浏览文件 @
1c81c18d
...
@@ -2,7 +2,17 @@ import type { Plugin } from 'vite'
...
@@ -2,7 +2,17 @@ import type { Plugin } from 'vite'
// https://github.com/antfu/unocss
// https://github.com/antfu/unocss
import
Unocss
from
'unocss/vite'
import
Unocss
from
'unocss/vite'
import
{
presetIcons
}
from
'unocss'
export
function
configUnocssPlugin
():
Plugin
[]
{
export
function
configUnocssPlugin
():
Plugin
[]
{
return
Unocss
()
return
Unocss
({
presets
:
[
presetIcons
({
prefix
:
'icon-'
,
extraProperties
:
{
display
:
'inline-flex'
,
},
}),
],
})
}
}
src/components/Icon/index.vue
0 → 100644
浏览文件 @
1c81c18d
<
script
setup
lang=
"ts"
>
const
props
=
defineProps
({
icon
:
{
type
:
String
,
required
:
true
,
},
size
:
{
type
:
Number
||
String
,
default
:
32
,
},
color
:
{
type
:
String
,
default
:
'#000'
,
},
})
const
size
=
computed
(()
=>
`
${
props
.
size
}
rpx`
)
const
color
=
computed
(()
=>
props
.
color
)
</
script
>
<
template
>
<view
class=
"icon"
/>
</
template
>
<
style
lang=
"less"
scoped
>
.icon
{
width
:
v-bind
(
size
);
height
:
v-bind
(
size
);
color
:
v-bind
(
color
);
}
</
style
>
src/pages/index/index.vue
浏览文件 @
1c81c18d
...
@@ -36,19 +36,32 @@
...
@@ -36,19 +36,32 @@
const
animate
=
ref
()
const
animate
=
ref
()
const
handUp
=
()
=>
{
const
handUp
=
()
=>
{
if
(
animate
.
value
)
{
return
}
Message
.
toast
(
'👋🏻'
)
Message
.
toast
(
'👋🏻'
)
animate
.
value
=
'animate-iteration-infinite'
animate
.
value
=
'animate-iteration-infinite'
setTimeout
(()
=>
(
animate
.
value
=
''
),
10
00
)
setTimeout
(()
=>
(
animate
.
value
=
null
),
15
00
)
}
}
</
script
>
</
script
>
<
template
>
<
template
>
<view
class=
"content flex-center flex-col"
>
<view
class=
"content flex-center flex-col"
>
<fui-avatar
src=
"/static/logo.png"
radius=
"14"
size=
"large"
background=
"transparent"
@
click=
"surprise"
/>
<fui-avatar
<view
class=
"flex flex-col justify-center mb-3"
>
src=
"/static/logo.png"
radius=
"14"
size=
"large"
background=
"transparent"
class=
"!mb-5"
@
click=
"surprise"
/>
<view
class=
"flex-center flex-col mb-5"
>
<text
class=
"title"
>
{{
title
}}
</text>
<text
class=
"title"
>
{{
title
}}
</text>
<text
class=
"title"
>
{{
$t
(
'app.hello'
)
}}
</text>
<text
class=
"title"
>
{{
$t
(
'app.hello'
)
}}
</text>
<uni-icons
type=
"hand-up"
size=
"30"
:class=
"['mt-5', 'animate-heart-beat', animate]"
@
click=
"handUp"
/>
<Icon
icon=
"emojione:grinning-face"
size=
"48"
class=
"m-3"
/>
<uni-icons
type=
"hand-up"
size=
"30"
class=
"mt-3 animate-swing"
:class=
"[animate]"
@
click=
"handUp"
/>
</view>
</view>
<fui-footer
isFixed
>
<fui-footer
isFixed
>
<template
#
text
>
<template
#
text
>
...
...
types/components.d.ts
浏览文件 @
1c81c18d
差异被折叠。
点击展开。
unocss.config.ts
浏览文件 @
1c81c18d
import
{
defineConfig
}
from
'unocss'
import
{
defineConfig
}
from
'unocss'
import
presetWeapp
from
'unocss-preset-weapp'
import
presetWeapp
from
'unocss-preset-weapp'
import
{
transformerAttributify
,
transformerClass
}
from
'unocss-preset-weapp/transformer'
import
{
defaultAttributes
,
transformerAttributify
,
transformerClass
}
from
'unocss-preset-weapp/transformer'
const
transformRules
=
{
':'
:
'-'
,
'.'
:
'_dl_'
,
'/'
:
'_sl_'
,
'%'
:
'_pes_'
,
'!'
:
'_el_'
,
'#'
:
'_wn_'
,
'('
:
'_lbl_'
,
')'
:
'_lbr_'
,
'['
:
'_lfl_'
,
']'
:
'_lfr_'
,
$
:
'_do_'
,
','
:
'_lco_'
,
'='
:
'_eqe_'
,
}
export
default
defineConfig
({
export
default
defineConfig
({
presets
:
[
presets
:
[
...
@@ -20,9 +36,14 @@ export default defineConfig({
...
@@ -20,9 +36,14 @@ export default defineConfig({
],
],
transformers
:
[
transformers
:
[
// https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
// https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
transformerAttributify
(),
transformerAttributify
({
attributes
:
[...
defaultAttributes
,
'icon'
],
transformRules
,
}),
// https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
// https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
transformerClass
(),
transformerClass
({
transformRules
,
}),
],
],
})
})
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论