feat: 添加自定义iconfont

This commit is contained in:
2025-06-04 17:45:32 +08:00
parent 82c55fece3
commit a12107da40
21 changed files with 3463 additions and 52 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"usingComponents": {},
"component": true
}
+21
View File
@@ -0,0 +1,21 @@
@import '../../style/theme.less';
@import '../../assets/font/iconfont.less';
.icon {
margin: 0;
padding: 0;
display: inline-block;
vertical-align: middle;
font-size: inherit;
color: inherit;
&.icon_image {
width: @font-size-icon;
height: @font-size-icon;
}
&__image {
width: 100%;
height: 100%;
}
}
+35
View File
@@ -0,0 +1,35 @@
Component({
options: {
//@ts-ignore
styleIsolation: 'apply-shared',
},
properties: {
// icon name
name: {
type: String,
value: '',
optionalTypes: [String],
},
// icon color
color: {
type: String,
value: '',
optionalTypes: [String],
},
// icon size
size: {
type: String,
value: '',
optionalTypes: [String],
},
// icon classPrefix
classPrefix: {
type: String,
value: 'icon',
optionalTypes: [String],
},
},
externalClasses: ['ext-class'],
data: {},
methods: {},
});
+4
View File
@@ -0,0 +1,4 @@
<wxs src="../wxs/base.wxs" module="Utils" />
<view class="{{ Utils.classNames('icon iconfont ' + classPrefix, { icon_image: Utils.isUrl(name)}) }} {{ !Utils.isUrl(name) && classPrefix + '-' + name }} ext-class" style="{{size ? 'font-size: ' + size + 'rpx;' : ''}}{{color ? 'color: ' + color + ';' : ''}}{{Utils.isUrl(name) && size ? 'width: ' + size + ';height: ' + size + ';' : ''}}">
<image wx:if="{{ Utils.isUrl(name) }}" src="{{ name }}" mode='aspectFit' class="icon__image" />
</view>