create-uniapps 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -167
- package/index.mjs +35 -17
- package/package.json +3 -4
- package/template/.prettierrc +9 -0
- package/template/.vscode/settings.json +27 -0
- package/template/LICENSE +21 -0
- package/template/README.md +2 -2
- package/template/eslint.config.ts +23 -0
- package/template/package-lock.json +17910 -14602
- package/template/package.json +5 -13
- package/template/prettier.config.ts +2 -2
- package/template/shims-uni.d.ts +3 -5
- package/template/src/App.vue +7 -6
- package/template/src/auto-imports.d.ts +1 -0
- package/template/src/env.d.ts +4 -4
- package/template/src/main.ts +6 -8
- package/template/src/manifest.json +71 -71
- package/template/src/pages/index/index.vue +5 -7
- package/template/src/pages.json +7 -9
- package/template/src/shime-uni.d.ts +5 -5
- package/template/src/static/css/index.scss +2 -0
- package/template/src/static/css/tailwind.css +1 -2
- package/template/src/uni_modules/uview-plus/components/u-icon/u-icon.vue +197 -179
- package/template/src/uni_modules/uview-plus/components/u-icon/util.js +61 -76
- package/template/src/uni_modules/uview-plus/libs/config/config.js +39 -39
- package/template/src/utils/config.ts +23 -0
- package/template/src/utils/request.ts +29 -11
- package/template/src/uview-plus.d.ts +1 -1
- package/template/tailwind.config.ts +1 -1
- package/template/tsconfig.json +8 -18
- package/template/vite.config.ts +9 -11
- package/template/eslint.config.mjs +0 -30
- package/template/src/static/font_2225171_8kdcwk4po24.ttf +0 -0
- package/template/src/uni_modules/uview-plus/components/u-icon/font_2225171_8kdcwk4po24.ttf +0 -0
- package/template/src/uni_modules/uview-plus/libs/font/font_2225171_8kdcwk4po24.ttf +0 -0
- /package/template/src/static/{logo.png → favicon.ico} +0 -0
- /package/template/src/types/{index.d.ts → global.d.ts} +0 -0
|
@@ -1,219 +1,237 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<view
|
|
3
|
+
class="u-icon"
|
|
4
|
+
@tap="clickHandler"
|
|
5
|
+
:class="['u-icon--' + labelPos]"
|
|
6
|
+
>
|
|
7
|
+
<image
|
|
8
|
+
class="u-icon__img"
|
|
9
|
+
v-if="isImg"
|
|
10
|
+
:src="name"
|
|
11
|
+
:mode="imgMode"
|
|
12
|
+
:style="[imgStyle, addStyle(customStyle)]"
|
|
13
|
+
></image>
|
|
14
|
+
<text
|
|
15
|
+
v-else
|
|
16
|
+
class="u-icon__icon"
|
|
17
|
+
:class="uClasses"
|
|
18
|
+
:style="[iconStyle, addStyle(customStyle)]"
|
|
19
|
+
:hover-class="hoverClass"
|
|
20
|
+
>{{icon}}</text>
|
|
7
21
|
<!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 -->
|
|
8
|
-
<text
|
|
22
|
+
<text
|
|
23
|
+
v-if="label !== ''"
|
|
24
|
+
class="u-icon__label"
|
|
25
|
+
:style="{
|
|
9
26
|
color: labelColor,
|
|
10
27
|
fontSize: addUnit(labelSize),
|
|
11
28
|
marginLeft: labelPos == 'right' ? addUnit(space) : 0,
|
|
12
29
|
marginTop: labelPos == 'bottom' ? addUnit(space) : 0,
|
|
13
30
|
marginRight: labelPos == 'left' ? addUnit(space) : 0,
|
|
14
31
|
marginBottom: labelPos == 'top' ? addUnit(space) : 0,
|
|
15
|
-
}"
|
|
32
|
+
}"
|
|
33
|
+
>{{ label }}</text>
|
|
16
34
|
</view>
|
|
17
35
|
</template>
|
|
18
36
|
|
|
19
37
|
<script>
|
|
20
|
-
// 引入图标名称,已经对应的unicode
|
|
21
|
-
import icons from './icons';
|
|
22
|
-
import { props } from './props';
|
|
23
|
-
import config from '../../libs/config/config';
|
|
24
|
-
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
25
|
-
import { mixin } from '../../libs/mixin/mixin';
|
|
26
|
-
import { addUnit, addStyle } from '../../libs/function/index';
|
|
27
|
-
import fontUtil from './util';
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export default {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
emits: ['click'],
|
|
64
|
-
mixins: [mpMixin, mixin, props],
|
|
65
|
-
computed: {
|
|
66
|
-
uClasses() {
|
|
67
|
-
let classes = []
|
|
68
|
-
classes.push(this.customPrefix + '-' + this.name)
|
|
69
|
-
// uview-plus内置图标类名为u-iconfont
|
|
70
|
-
if (this.customPrefix == 'uicon') {
|
|
71
|
-
classes.push('u-iconfont')
|
|
72
|
-
} else {
|
|
73
|
-
// 不能缺少这一步,否则自定义图标会无效
|
|
74
|
-
classes.push(this.customPrefix)
|
|
38
|
+
// 引入图标名称,已经对应的unicode
|
|
39
|
+
import icons from './icons';
|
|
40
|
+
import { props } from './props';
|
|
41
|
+
import config from '../../libs/config/config';
|
|
42
|
+
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
43
|
+
import { mixin } from '../../libs/mixin/mixin';
|
|
44
|
+
import { addUnit, addStyle } from '../../libs/function/index';
|
|
45
|
+
import fontUtil from './util';
|
|
46
|
+
/**
|
|
47
|
+
* icon 图标
|
|
48
|
+
* @description 基于字体的图标集,包含了大多数常见场景的图标。
|
|
49
|
+
* @tutorial https://ijry.github.io/uview-plus/components/icon.html
|
|
50
|
+
* @property {String} name 图标名称,见示例图标集
|
|
51
|
+
* @property {String} color 图标颜色,可接受主题色 (默认 color['u-content-color'] )
|
|
52
|
+
* @property {String | Number} size 图标字体大小,单位px (默认 '16px' )
|
|
53
|
+
* @property {Boolean} bold 是否显示粗体 (默认 false )
|
|
54
|
+
* @property {String | Number} index 点击图标的时候传递事件出去的index(用于区分点击了哪一个)
|
|
55
|
+
* @property {String} hoverClass 图标按下去的样式类,用法同uni的view组件的hoverClass参数,详情见官网
|
|
56
|
+
* @property {String} customPrefix 自定义扩展前缀,方便用户扩展自己的图标库 (默认 'uicon' )
|
|
57
|
+
* @property {String | Number} label 图标右侧的label文字
|
|
58
|
+
* @property {String} labelPos label相对于图标的位置,只能right或bottom (默认 'right' )
|
|
59
|
+
* @property {String | Number} labelSize label字体大小,单位px (默认 '15px' )
|
|
60
|
+
* @property {String} labelColor 图标右侧的label文字颜色 ( 默认 color['u-content-color'] )
|
|
61
|
+
* @property {String | Number} space label与图标的距离,单位px (默认 '3px' )
|
|
62
|
+
* @property {String} imgMode 图片的mode
|
|
63
|
+
* @property {String | Number} width 显示图片小图标时的宽度
|
|
64
|
+
* @property {String | Number} height 显示图片小图标时的高度
|
|
65
|
+
* @property {String | Number} top 图标在垂直方向上的定位 用于解决某些情况下,让图标垂直居中的用途 (默认 0 )
|
|
66
|
+
* @property {Boolean} stop 是否阻止事件传播 (默认 false )
|
|
67
|
+
* @property {Object} customStyle icon的样式,对象形式
|
|
68
|
+
* @event {Function} click 点击图标时触发
|
|
69
|
+
* @event {Function} touchstart 事件触摸时触发
|
|
70
|
+
* @example <u-icon name="photo" color="#2979ff" size="28"></u-icon>
|
|
71
|
+
*/
|
|
72
|
+
export default {
|
|
73
|
+
name: 'u-icon',
|
|
74
|
+
beforeCreate() {
|
|
75
|
+
fontUtil.loadFont();
|
|
76
|
+
},
|
|
77
|
+
data() {
|
|
78
|
+
return {
|
|
75
79
|
}
|
|
76
|
-
// 主题色,通过类配置
|
|
77
|
-
if (this.color && config.type.includes(this.color)) classes.push('u-icon__icon--' + this.color)
|
|
78
|
-
// 阿里,头条,百度小程序通过数组绑定类名时,无法直接使用[a, b, c]的形式,否则无法识别
|
|
79
|
-
// 故需将其拆成一个字符串的形式,通过空格隔开各个类名
|
|
80
|
-
//#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
|
|
81
|
-
classes = classes.join(' ')
|
|
82
|
-
//#endif
|
|
83
|
-
return classes
|
|
84
80
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
emits: ['click'],
|
|
82
|
+
mixins: [mpMixin, mixin, props],
|
|
83
|
+
computed: {
|
|
84
|
+
uClasses() {
|
|
85
|
+
let classes = []
|
|
86
|
+
classes.push(this.customPrefix + '-' + this.name)
|
|
87
|
+
// uview-plus内置图标类名为u-iconfont
|
|
88
|
+
if (this.customPrefix == 'uicon') {
|
|
89
|
+
classes.push('u-iconfont')
|
|
90
|
+
} else {
|
|
91
|
+
// 不能缺少这一步,否则自定义图标会无效
|
|
92
|
+
classes.push(this.customPrefix)
|
|
93
|
+
}
|
|
94
|
+
// 主题色,通过类配置
|
|
95
|
+
if (this.color && config.type.includes(this.color)) classes.push('u-icon__icon--' + this.color)
|
|
96
|
+
// 阿里,头条,百度小程序通过数组绑定类名时,无法直接使用[a, b, c]的形式,否则无法识别
|
|
97
|
+
// 故需将其拆成一个字符串的形式,通过空格隔开各个类名
|
|
98
|
+
//#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
|
|
99
|
+
classes = classes.join(' ')
|
|
100
|
+
//#endif
|
|
101
|
+
return classes
|
|
102
|
+
},
|
|
103
|
+
iconStyle() {
|
|
104
|
+
let style = {}
|
|
105
|
+
style = {
|
|
106
|
+
fontSize: addUnit(this.size),
|
|
107
|
+
lineHeight: addUnit(this.size),
|
|
108
|
+
fontWeight: this.bold ? 'bold' : 'normal',
|
|
109
|
+
// 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
|
|
110
|
+
top: addUnit(this.top)
|
|
111
|
+
}
|
|
112
|
+
if (this.customPrefix !== 'uicon') {
|
|
113
|
+
style.fontFamily = this.customPrefix
|
|
114
|
+
}
|
|
115
|
+
// 非主题色值时,才当作颜色值
|
|
116
|
+
if (this.color && !config.type.includes(this.color)) style.color = this.color
|
|
117
|
+
|
|
118
|
+
return style
|
|
119
|
+
},
|
|
120
|
+
// 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
|
|
121
|
+
isImg() {
|
|
122
|
+
return this.name.indexOf('/') !== -1
|
|
123
|
+
},
|
|
124
|
+
imgStyle() {
|
|
125
|
+
let style = {}
|
|
126
|
+
// 如果设置width和height属性,则优先使用,否则使用size属性
|
|
127
|
+
style.width = this.width ? addUnit(this.width) : addUnit(this.size)
|
|
128
|
+
style.height = this.height ? addUnit(this.height) : addUnit(this.size)
|
|
129
|
+
return style
|
|
130
|
+
},
|
|
131
|
+
// 通过图标名,查找对应的图标
|
|
132
|
+
icon() {
|
|
133
|
+
// 使用自定义图标的时候页面上会把name属性也展示出来,所以在这里处理一下
|
|
134
|
+
if (this.customPrefix !== "uicon") {
|
|
135
|
+
return config.customIcons[this.name] || this.name;
|
|
136
|
+
}
|
|
137
|
+
// 如果内置的图标中找不到对应的图标,就直接返回name值,因为用户可能传入的是unicode代码
|
|
138
|
+
return icons['uicon-' + this.name] || this.name
|
|
96
139
|
}
|
|
97
|
-
// 非主题色值时,才当作颜色值
|
|
98
|
-
if (this.color && !config.type.includes(this.color)) style.color = this.color
|
|
99
|
-
|
|
100
|
-
return style
|
|
101
|
-
},
|
|
102
|
-
// 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
|
|
103
|
-
isImg() {
|
|
104
|
-
return this.name.indexOf('/') !== -1
|
|
105
|
-
},
|
|
106
|
-
imgStyle() {
|
|
107
|
-
let style = {}
|
|
108
|
-
// 如果设置width和height属性,则优先使用,否则使用size属性
|
|
109
|
-
style.width = this.width ? addUnit(this.width) : addUnit(this.size)
|
|
110
|
-
style.height = this.height ? addUnit(this.height) : addUnit(this.size)
|
|
111
|
-
return style
|
|
112
140
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
methods: {
|
|
142
|
+
addStyle,
|
|
143
|
+
addUnit,
|
|
144
|
+
clickHandler(e) {
|
|
145
|
+
this.$emit('click', this.index, e)
|
|
146
|
+
// 是否阻止事件冒泡
|
|
147
|
+
this.stop && this.preventEvent(e)
|
|
118
148
|
}
|
|
119
|
-
// 如果内置的图标中找不到对应的图标,就直接返回name值,因为用户可能传入的是unicode代码
|
|
120
|
-
return icons['uicon-' + this.name] || this.name
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
methods: {
|
|
124
|
-
addStyle,
|
|
125
|
-
addUnit,
|
|
126
|
-
clickHandler(e) {
|
|
127
|
-
this.$emit('click', this.index, e)
|
|
128
|
-
// 是否阻止事件冒泡
|
|
129
|
-
this.stop && this.preventEvent(e)
|
|
130
149
|
}
|
|
131
150
|
}
|
|
132
|
-
}
|
|
133
151
|
</script>
|
|
134
152
|
|
|
135
153
|
<style lang="scss" scoped>
|
|
136
|
-
// 变量定义
|
|
137
|
-
$u-icon-primary: $u-primary !default;
|
|
138
|
-
$u-icon-success: $u-success !default;
|
|
139
|
-
$u-icon-info: $u-info !default;
|
|
140
|
-
$u-icon-warning: $u-warning !default;
|
|
141
|
-
$u-icon-error: $u-error !default;
|
|
142
|
-
$u-icon-label-line-height: 1 !default;
|
|
143
|
-
|
|
144
|
-
/* #ifdef MP-QQ || MP-TOUTIAO || MP-BAIDU || MP-KUAISHOU || MP-XHS */
|
|
145
|
-
// 2025/04/09在App/微信/支付宝/鸿蒙元服务已改用uni.loadFontFace加载字体
|
|
146
|
-
@font-face {
|
|
147
|
-
font-family: 'uicon-iconfont';
|
|
148
|
-
src: url('./font_2225171_8kdcwk4po24.ttf') format('truetype');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/* #endif */
|
|
152
|
-
|
|
153
|
-
.u-icon {
|
|
154
|
-
/* #ifndef APP-NVUE */
|
|
155
|
-
display: flex;
|
|
156
|
-
/* #endif */
|
|
157
|
-
align-items: center;
|
|
158
|
-
|
|
159
|
-
&--left {
|
|
160
|
-
flex-direction: row-reverse;
|
|
161
|
-
align-items: center;
|
|
162
|
-
}
|
|
163
154
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
155
|
+
// 变量定义
|
|
156
|
+
$u-icon-primary: $u-primary !default;
|
|
157
|
+
$u-icon-success: $u-success !default;
|
|
158
|
+
$u-icon-info: $u-info !default;
|
|
159
|
+
$u-icon-warning: $u-warning !default;
|
|
160
|
+
$u-icon-error: $u-error !default;
|
|
161
|
+
$u-icon-label-line-height:1 !default;
|
|
162
|
+
|
|
163
|
+
/* #ifdef MP-QQ || MP-TOUTIAO || MP-BAIDU || MP-KUAISHOU || MP-XHS */
|
|
164
|
+
// 2025/04/09在App/微信/支付宝/鸿蒙元服务已改用uni.loadFontFace加载字体
|
|
165
|
+
@font-face {
|
|
166
|
+
font-family: 'uicon-iconfont';
|
|
167
|
+
src: url('https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf') format('truetype');
|
|
177
168
|
}
|
|
169
|
+
/* #endif */
|
|
178
170
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
171
|
+
.u-icon {
|
|
172
|
+
/* #ifndef APP-NVUE */
|
|
173
|
+
display: flex;
|
|
174
|
+
/* #endif */
|
|
183
175
|
align-items: center;
|
|
184
176
|
|
|
185
|
-
&--
|
|
186
|
-
|
|
177
|
+
&--left {
|
|
178
|
+
flex-direction: row-reverse;
|
|
179
|
+
align-items: center;
|
|
187
180
|
}
|
|
188
181
|
|
|
189
|
-
&--
|
|
190
|
-
|
|
182
|
+
&--right {
|
|
183
|
+
flex-direction: row;
|
|
184
|
+
align-items: center;
|
|
191
185
|
}
|
|
192
186
|
|
|
193
|
-
&--
|
|
194
|
-
|
|
187
|
+
&--top {
|
|
188
|
+
flex-direction: column-reverse;
|
|
189
|
+
justify-content: center;
|
|
195
190
|
}
|
|
196
191
|
|
|
197
|
-
&--
|
|
198
|
-
|
|
192
|
+
&--bottom {
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
justify-content: center;
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
&__icon {
|
|
198
|
+
font-family: uicon-iconfont;
|
|
199
|
+
position: relative;
|
|
200
|
+
@include flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
|
|
203
|
+
&--primary {
|
|
204
|
+
color: $u-icon-primary;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&--success {
|
|
208
|
+
color: $u-icon-success;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&--error {
|
|
212
|
+
color: $u-icon-error;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&--warning {
|
|
216
|
+
color: $u-icon-warning;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&--info {
|
|
220
|
+
color: $u-icon-info;
|
|
221
|
+
}
|
|
203
222
|
}
|
|
204
|
-
}
|
|
205
223
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
224
|
+
&__img {
|
|
225
|
+
/* #ifndef APP-NVUE */
|
|
226
|
+
height: auto;
|
|
227
|
+
will-change: transform;
|
|
228
|
+
/* #endif */
|
|
229
|
+
}
|
|
212
230
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
231
|
+
&__label {
|
|
232
|
+
/* #ifndef APP-NVUE */
|
|
233
|
+
line-height: $u-icon-label-line-height;
|
|
234
|
+
/* #endif */
|
|
235
|
+
}
|
|
217
236
|
}
|
|
218
|
-
}
|
|
219
237
|
</style>
|
|
@@ -1,90 +1,75 @@
|
|
|
1
1
|
import config from '../../libs/config/config';
|
|
2
2
|
// 定义高阶函数
|
|
3
3
|
function once(fn) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
let called = false;
|
|
5
|
+
let result;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
return function(...args) {
|
|
8
|
+
if (!called) {
|
|
9
|
+
result = fn.apply(this, args);
|
|
10
|
+
called = true;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// 使用高阶函数
|
|
17
17
|
const loadFont = once(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fail() {
|
|
70
|
-
// console.error('扩展字体图标加载出错');
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// #endif
|
|
75
|
-
// #ifdef APP-NVUE
|
|
76
|
-
if (this.customFontFamily) {
|
|
77
|
-
domModule.addRule('fontFace', {
|
|
78
|
-
'fontFamily': `${this.customPrefix}-${this.customFontFamily}`,
|
|
79
|
-
'src': `url('${this.customFontUrl}')`
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
// #endif
|
|
83
|
-
return true;
|
|
18
|
+
// console.log('这个函数只能执行一次');
|
|
19
|
+
// #ifdef APP-NVUE
|
|
20
|
+
// nvue通过weex的dom模块引入字体,相关文档地址如下:
|
|
21
|
+
// https://weex.apache.org/zh/docs/modules/dom.html#addrule
|
|
22
|
+
const domModule = weex.requireModule('dom');
|
|
23
|
+
domModule.addRule('fontFace', {
|
|
24
|
+
'fontFamily': "uicon-iconfont",
|
|
25
|
+
'src': `url('${config.iconUrl}')`
|
|
26
|
+
});
|
|
27
|
+
if (config.customIcon.family) {
|
|
28
|
+
domModule.addRule('fontFace', {
|
|
29
|
+
'fontFamily': config.customIcon.family,
|
|
30
|
+
'src': `url('${config.customIcon.url}')`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// #endif
|
|
34
|
+
// #ifdef APP || H5 || MP-WEIXIN || MP-ALIPAY
|
|
35
|
+
uni.loadFontFace({
|
|
36
|
+
global: true, // 是否全局生效。微信小程序 '2.10.0'起支持全局生效,需在 app.vue 中调用。
|
|
37
|
+
family: 'uicon-iconfont',
|
|
38
|
+
source: 'url("' + config.iconUrl + '")',
|
|
39
|
+
success() {
|
|
40
|
+
// console.log('内置字体图标加载成功');
|
|
41
|
+
},
|
|
42
|
+
fail() {
|
|
43
|
+
// console.error('内置字体图标加载出错');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (config.customIcon.family) {
|
|
47
|
+
uni.loadFontFace({
|
|
48
|
+
global: true, // 是否全局生效。微信小程序 '2.10.0'起支持全局生效,需在 app.vue 中调用。
|
|
49
|
+
family: config.customIcon.family,
|
|
50
|
+
source: 'url("' + config.customIcon.url + '")',
|
|
51
|
+
success() {
|
|
52
|
+
// console.log('扩展字体图标加载成功');
|
|
53
|
+
},
|
|
54
|
+
fail() {
|
|
55
|
+
// console.error('扩展字体图标加载出错');
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// #endif
|
|
60
|
+
// #ifdef APP-NVUE
|
|
61
|
+
if (this.customFontFamily) {
|
|
62
|
+
domModule.addRule('fontFace', {
|
|
63
|
+
'fontFamily': `${this.customPrefix}-${this.customFontFamily}`,
|
|
64
|
+
'src': `url('${this.customFontUrl}')`
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
// #endif
|
|
68
|
+
return true;
|
|
84
69
|
});
|
|
85
70
|
|
|
86
71
|
let fontUtil = {
|
|
87
|
-
|
|
72
|
+
loadFont
|
|
88
73
|
}
|
|
89
74
|
|
|
90
75
|
export default fontUtil
|
|
@@ -6,45 +6,45 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
v: version,
|
|
10
|
+
version,
|
|
11
|
+
// 主题名称
|
|
12
|
+
type: [
|
|
13
|
+
'primary',
|
|
14
|
+
'success',
|
|
15
|
+
'info',
|
|
16
|
+
'error',
|
|
17
|
+
'warning'
|
|
18
|
+
],
|
|
19
|
+
// 颜色部分,本来可以通过scss的:export导出供js使用,但是奈何nvue不支持
|
|
20
|
+
color: {
|
|
21
|
+
'u-primary': '#2979ff',
|
|
22
|
+
'u-warning': '#ff9900',
|
|
23
|
+
'u-success': '#19be6b',
|
|
24
|
+
'u-error': '#fa3534',
|
|
25
|
+
'u-info': '#909399',
|
|
26
|
+
'u-main-color': '#303133',
|
|
27
|
+
'u-content-color': '#606266',
|
|
28
|
+
'u-tips-color': '#909399',
|
|
29
|
+
'u-light-color': '#c0c4cc',
|
|
30
|
+
'up-primary': '#2979ff',
|
|
31
|
+
'up-warning': '#ff9900',
|
|
32
|
+
'up-success': '#19be6b',
|
|
33
|
+
'up-error': '#fa3534',
|
|
34
|
+
'up-info': '#909399',
|
|
35
|
+
'up-main-color': '#303133',
|
|
36
|
+
'up-content-color': '#606266',
|
|
37
|
+
'up-tips-color': '#909399',
|
|
38
|
+
'up-light-color': '#c0c4cc'
|
|
39
|
+
},
|
|
40
|
+
// 字体图标地址
|
|
41
|
+
iconUrl: 'https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf',
|
|
42
|
+
// 自定义图标
|
|
43
|
+
customIcon: {
|
|
44
|
+
family: '',
|
|
45
|
+
url: ''
|
|
46
|
+
},
|
|
47
|
+
customIcons: {}, // 自定义图标与unicode对应关系
|
|
48
48
|
// 默认单位,可以通过配置为rpx,那么在用于传入组件大小参数为数值时,就默认为rpx
|
|
49
49
|
unit: 'px',
|
|
50
50
|
// 拦截器
|