uview-plus 3.4.53 → 3.4.54

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,8 @@
1
+ ## 3.4.54(2025-07-18)
2
+ feat: dropdown组件的highlight方法支持同时高亮多个菜单项
3
+
4
+ feat: 支持一次性全局加载icon字体
5
+
1
6
  ## 3.4.53(2025-07-18)
2
7
  feat: dropdown组件的highlight方法支持同时高亮多个菜单项 感谢@keeplearning66
3
8
 
@@ -8,13 +8,13 @@
8
8
  <view class="u-dropdown__menu__item" v-for="(item, index) in menuList" :key="index" @tap.stop="menuClick(index)">
9
9
  <view class="u-flex u-flex-row">
10
10
  <text class="u-dropdown__menu__item__text" :style="{
11
- color: item.disabled ? '#c0c4cc' : (index === current || highlightIndex == index) ? activeColor : inactiveColor,
11
+ color: item.disabled ? '#c0c4cc' : (index === current || highlightIndexList.includes(index)) ? activeColor : inactiveColor,
12
12
  fontSize: addUnit(titleSize)
13
13
  }">{{item.title}}</text>
14
14
  <view class="u-dropdown__menu__item__arrow" :class="{
15
15
  'u-dropdown__menu__item__arrow--rotate': index === current
16
16
  }">
17
- <u-icon :custom-style="{display: 'flex'}" :name="menuIcon" :size="addUnit(menuIconSize)" :color="index === current || highlightIndex == index ? activeColor : '#c0c4cc'"></u-icon>
17
+ <u-icon :custom-style="{display: 'flex'}" :name="menuIcon" :size="addUnit(menuIconSize)" :color="index === current || highlightIndexList.includes(index) ? activeColor : '#c0c4cc'"></u-icon>
18
18
  </view>
19
19
  </view>
20
20
  </view>
@@ -71,8 +71,8 @@
71
71
  zIndex: -1,
72
72
  opacity: 0
73
73
  },
74
- // 让某个菜单保持高亮的状态
75
- highlightIndex: 99999,
74
+ // 让某些菜单保持高亮的状态
75
+ highlightIndexList: [],
76
76
  contentHeight: 0
77
77
  }
78
78
  },
@@ -160,9 +160,13 @@
160
160
  if (!this.closeOnClickMask) return;
161
161
  this.close();
162
162
  },
163
- // 外部手动设置某个菜单高亮
164
- highlight(index = undefined) {
165
- this.highlightIndex = index !== undefined ? index : 99999;
163
+ // 外部手动设置某些菜单高亮
164
+ highlight(indexParams = undefined) {
165
+ if (Array.isArray(indexParams)) {
166
+ this.highlightIndexList = [...indexParams];
167
+ return;
168
+ }
169
+ this.highlightIndexList = indexParams !== undefined ? [indexParams] : [];
166
170
  },
167
171
  // 获取下拉菜单内容的高度
168
172
  getContentHeight() {
@@ -42,6 +42,7 @@
42
42
  import { mpMixin } from '../../libs/mixin/mpMixin';
43
43
  import { mixin } from '../../libs/mixin/mixin';
44
44
  import { addUnit, addStyle } from '../../libs/function/index';
45
+ import fontUtil from './util';
45
46
  /**
46
47
  * icon 图标
47
48
  * @description 基于字体的图标集,包含了大多数常见场景的图标。
@@ -71,54 +72,7 @@
71
72
  export default {
72
73
  name: 'u-icon',
73
74
  beforeCreate() {
74
-
75
- // #ifdef APP-NVUE
76
- // nvue通过weex的dom模块引入字体,相关文档地址如下:
77
- // https://weex.apache.org/zh/docs/modules/dom.html#addrule
78
- const domModule = weex.requireModule('dom');
79
- domModule.addRule('fontFace', {
80
- 'fontFamily': "uicon-iconfont",
81
- 'src': `url('${config.iconUrl}')`
82
- });
83
- if (config.customIcon.family) {
84
- domModule.addRule('fontFace', {
85
- 'fontFamily': config.customIcon.family,
86
- 'src': `url('${config.customIcon.url}')`
87
- });
88
- }
89
- // #endif
90
- // #ifdef APP || H5 || MP-WEIXIN || MP-ALIPAY
91
- uni.loadFontFace({
92
- family: 'uicon-iconfont',
93
- source: 'url("' + config.iconUrl + '")',
94
- success() {
95
- // console.log('内置字体图标加载成功');
96
- },
97
- fail() {
98
- // console.error('内置字体图标加载出错');
99
- }
100
- });
101
- if (config.customIcon.family) {
102
- uni.loadFontFace({
103
- family: config.customIcon.family,
104
- source: 'url("' + config.customIcon.url + '")',
105
- success() {
106
- // console.log('扩展字体图标加载成功');
107
- },
108
- fail() {
109
- // console.error('扩展字体图标加载出错');
110
- }
111
- });
112
- }
113
- // #endif
114
- // #ifdef APP-NVUE
115
- if (this.customFontFamily) {
116
- domModule.addRule('fontFace', {
117
- 'fontFamily': `${this.customPrefix}-${this.customFontFamily}`,
118
- 'src': `url('${this.customFontUrl}')`
119
- })
120
- }
121
- // #endif
75
+ fontUtil.loadFont();
122
76
  },
123
77
  data() {
124
78
  return {
@@ -7,7 +7,7 @@ function once(fn) {
7
7
  return function(...args) {
8
8
  if (!called) {
9
9
  result = fn.apply(this, args);
10
- // called = true;
10
+ called = true;
11
11
  }
12
12
  return result;
13
13
  };
@@ -15,7 +15,7 @@ function once(fn) {
15
15
 
16
16
  // 使用高阶函数
17
17
  const loadFont = once(() => {
18
- console.log('这个函数只能执行一次');
18
+ // console.log('这个函数只能执行一次');
19
19
  // #ifdef APP-NVUE
20
20
  // nvue通过weex的dom模块引入字体,相关文档地址如下:
21
21
  // https://weex.apache.org/zh/docs/modules/dom.html#addrule
@@ -33,6 +33,7 @@ const loadFont = once(() => {
33
33
  // #endif
34
34
  // #ifdef APP || H5 || MP-WEIXIN || MP-ALIPAY
35
35
  uni.loadFontFace({
36
+ global: true, // 是否全局生效。微信小程序 '2.10.0'起支持全局生效,需在 app.vue 中调用。
36
37
  family: 'uicon-iconfont',
37
38
  source: 'url("' + config.iconUrl + '")',
38
39
  success() {
@@ -44,6 +45,7 @@ const loadFont = once(() => {
44
45
  });
45
46
  if (config.customIcon.family) {
46
47
  uni.loadFontFace({
48
+ global: true, // 是否全局生效。微信小程序 '2.10.0'起支持全局生效,需在 app.vue 中调用。
47
49
  family: config.customIcon.family,
48
50
  source: 'url("' + config.customIcon.url + '")',
49
51
  success() {
@@ -66,8 +68,8 @@ const loadFont = once(() => {
66
68
  return true;
67
69
  });
68
70
 
69
- let util = {
71
+ let fontUtil = {
70
72
  loadFont
71
73
  }
72
74
 
73
- export default util
75
+ export default fontUtil
package/index.js CHANGED
@@ -38,9 +38,12 @@ import platform from './libs/function/platform'
38
38
  // http
39
39
  import http from './libs/function/http.js'
40
40
 
41
+ // fontUtil
42
+ import fontUtil from './components/u-icon/util.js';
43
+
41
44
  // 导出
42
45
  let themeType = ['primary', 'success', 'error', 'warning', 'info'];
43
- export { route, http, debounce, throttle, calc, digit, platform, themeType, mixin, mpMixin, props, color, test, zIndex }
46
+ export { route, http, debounce, throttle, calc, digit, platform, themeType, mixin, mpMixin, props, color, test, zIndex, fontUtil }
44
47
  export * from './libs/function/index.js'
45
48
  export * from './libs/function/colorGradient.js'
46
49
 
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.53",
5
+ "version": "3.4.54",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",