uview-plus 3.4.13 → 3.4.14

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/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.4.14(2025-04-09)
2
+ feat: 支持自托管内置图标及扩展自定义图标
3
+
1
4
  ## 3.4.13(2025-04-08)
2
5
  fix: tabs点击当前tab触发change事件
3
6
 
@@ -35,24 +35,47 @@
35
35
  </template>
36
36
 
37
37
  <script>
38
+ import config from '../../libs/config/config';
38
39
  // #ifdef APP-NVUE
39
40
  // nvue通过weex的dom模块引入字体,相关文档地址如下:
40
41
  // https://weex.apache.org/zh/docs/modules/dom.html#addrule
41
- const fontUrl = 'https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf'
42
- const domModule = weex.requireModule('dom')
42
+ const domModule = weex.requireModule('dom');
43
43
  domModule.addRule('fontFace', {
44
44
  'fontFamily': "uicon-iconfont",
45
- 'src': `url('${fontUrl}')`
46
- })
45
+ 'src': `url('${config.iconUrl}')`
46
+ });
47
+ // #endif
48
+ // #ifdef APP || H5 || MP-WEIXIN || MP-ALIPAY
49
+ uni.loadFontFace({
50
+ family: 'uicon-iconfont',
51
+ source: 'url("' + config.iconUrl + '")',
52
+ success() {
53
+ // console.log('内置字体图标加载成功');
54
+ },
55
+ fail() {
56
+ console.error('内置字体图标加载出错');
57
+ }
58
+ });
59
+ if (config.customIcon.family) {
60
+ uni.loadFontFace({
61
+ family: config.customIcon.family,
62
+ source: 'url("' + config.customIcon.url + '")',
63
+ success() {
64
+ // console.log('扩展字体图标加载成功');
65
+ },
66
+ fail() {
67
+ console.error('扩展字体图标加载出错');
68
+ }
69
+ });
70
+ }
47
71
  // #endif
48
72
 
49
73
  // 引入图标名称,已经对应的unicode
50
- import icons from './icons'
74
+ import icons from './icons';
51
75
  import { props } from './props';
52
76
  import { mpMixin } from '../../libs/mixin/mpMixin';
53
77
  import { mixin } from '../../libs/mixin/mixin';
54
78
  import { addUnit, addStyle } from '../../libs/function/index';
55
- import config from '../../libs/config/config';
56
79
  /**
57
80
  * icon 图标
58
81
  * @description 基于字体的图标集,包含了大多数常见场景的图标。
@@ -93,7 +116,6 @@
93
116
  },
94
117
  data() {
95
118
  return {
96
-
97
119
  }
98
120
  },
99
121
  emits: ['click'],
@@ -102,7 +124,7 @@
102
124
  uClasses() {
103
125
  let classes = []
104
126
  classes.push(this.customPrefix + '-' + this.name)
105
- // uView的自定义图标类名为u-iconfont
127
+ // uview-plus内置图标类名为u-iconfont
106
128
  if (this.customPrefix == 'uicon') {
107
129
  classes.push('u-iconfont')
108
130
  } else {
@@ -127,6 +149,9 @@
127
149
  // 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
128
150
  top: addUnit(this.top)
129
151
  }
152
+ if (this.customPrefix !== 'uicon') {
153
+ style.fontFamily = this.customPrefix
154
+ }
130
155
  // 非主题色值时,才当作颜色值
131
156
  if (this.color && !config.type.includes(this.color)) style.color = this.color
132
157
 
@@ -147,7 +172,7 @@
147
172
  icon() {
148
173
  // 使用自定义图标的时候页面上会把name属性也展示出来,所以在这里处理一下
149
174
  if (this.customPrefix !== "uicon") {
150
- return this.customIcons[this.customPrefix + '-' + this.name] || this.name;
175
+ return config.customIcons[this.name] || this.name;
151
176
  }
152
177
  // 如果内置的图标中找不到对应的图标,就直接返回name值,因为用户可能传入的是unicode代码
153
178
  return icons['uicon-' + this.name] || this.name
@@ -176,13 +201,12 @@
176
201
  $u-icon-error: $u-error !default;
177
202
  $u-icon-label-line-height:1 !default;
178
203
 
179
- /* #ifndef APP-NVUE */
180
- // 非nvue下加载字体
204
+ /* #ifdef MP-QQ || MP-TOUTIAO || MP-BAIDU || MP-KUAISHOU || MP-XHS */
205
+ // 2025/04/09在App/微信/支付宝/鸿蒙元服务已改用uni.loadFontFace加载字体
181
206
  @font-face {
182
207
  font-family: 'uicon-iconfont';
183
208
  src: url('https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf') format('truetype');
184
209
  }
185
-
186
210
  /* #endif */
187
211
 
188
212
  .u-icon {
package/index.js CHANGED
@@ -17,6 +17,8 @@ import test from './libs/function/test.js'
17
17
  import debounce from './libs/function/debounce.js'
18
18
  // 节流方法
19
19
  import throttle from './libs/function/throttle.js'
20
+ // 浮点计算
21
+ import calc from './libs/function/calc.js'
20
22
  // 公共文件写入的方法
21
23
  import index from './libs/function/index.js'
22
24
 
@@ -36,7 +38,7 @@ import http from './libs/function/http.js'
36
38
 
37
39
  // 导出
38
40
  let themeType = ['primary', 'success', 'error', 'warning', 'info'];
39
- export { route, http, debounce, throttle, platform, themeType, mixin, mpMixin, props, color, test, zIndex }
41
+ export { route, http, debounce, throttle, calc, platform, themeType, mixin, mpMixin, props, color, test, zIndex }
40
42
  export * from './libs/function/index.js'
41
43
  export * from './libs/function/colorGradient.js'
42
44
 
@@ -69,6 +71,7 @@ const $u = {
69
71
  zIndex,
70
72
  debounce,
71
73
  throttle,
74
+ calc,
72
75
  mixin,
73
76
  mpMixin,
74
77
  props,
@@ -37,6 +37,14 @@ export default {
37
37
  'up-tips-color': '#909399',
38
38
  'up-light-color': '#c0c4cc'
39
39
  },
40
+ // 字体图标地址
41
+ iconUrl: 'https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf',
42
+ // 自定义图标
43
+ customIcon: {
44
+ family: '',
45
+ url: ''
46
+ },
47
+ customIcons: {}, // 自定义图标与unicode对应关系
40
48
  // 默认单位,可以通过配置为rpx,那么在用于传入组件大小参数为数值时,就默认为rpx
41
49
  unit: 'px',
42
50
  // 拦截器
@@ -0,0 +1,64 @@
1
+ // 浮点数加法
2
+ export function add (arg1, arg2) {
3
+ var r1, r2, m
4
+ try {
5
+ r1 = arg1.toString().split('.')[1].length
6
+ } catch (e) {
7
+ r1 = 0
8
+ }
9
+ try {
10
+ r2 = arg2.toString().split('.')[1].length
11
+ } catch (e) {
12
+ r2 = 0
13
+ }
14
+ m = Math.pow(10, Math.max(r1, r2))
15
+ return (arg1 * m + arg2 * m) / m
16
+ }
17
+ // 浮点数减法
18
+ export function sub (arg1, arg2) {
19
+ var r1, r2, m, n
20
+ try {
21
+ r1 = arg1.toString().split('.')[1].length
22
+ } catch (e) {
23
+ r1 = 0
24
+ }
25
+ try {
26
+ r2 = arg2.toString().split('.')[1].length
27
+ } catch (e) {
28
+ r2 = 0
29
+ }
30
+ m = Math.pow(10, Math.max(r1, r2))
31
+ n = (r1 >= r2) ? r1 : r2
32
+ return Math.abs(((arg1 * m - arg2 * m) / m).toFixed(n))
33
+ }
34
+ //浮点乘法
35
+ export function mul (a, b) {
36
+ var c = 0,
37
+ d = a.toString(),
38
+ e = b.toString();
39
+ try {
40
+ c += d.split(".")[1].length;
41
+ } catch (f) {}
42
+ try {
43
+ c += e.split(".")[1].length;
44
+ } catch (f) {}
45
+ return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
46
+ }
47
+ //浮点除法
48
+ export function div (a, b) {
49
+ var c, d, e = 0,
50
+ f = 0;
51
+ try {
52
+ e = a.toString().split(".")[1].length;
53
+ } catch (g) {}
54
+ try {
55
+ f = b.toString().split(".")[1].length;
56
+ } catch (g) {}
57
+ return c = Number(a.toString().replace(".", "")), d = Number(b.toString().replace(".", "")), xyutil.mul(c / d, Math.pow(10, f - e));
58
+ }
59
+ export default {
60
+ add,
61
+ sub,
62
+ mul,
63
+ div
64
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.13",
5
+ "version": "3.4.14",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",