uview-plus 3.8.130 → 3.8.136

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.
@@ -21,13 +21,20 @@
21
21
  <view
22
22
  class="u-keyboard__button-wrapper"
23
23
  >
24
+ <!--
25
+ 退格键的删除由 @tap 触发(PC 端浏览器只有鼠标事件,不产生 touch);
26
+ @touchstart 只负责延时进入长按连删,短按时定时器会在 touchend 前被清除,所以不会删两次。
27
+ 注意:@touchstart 上不能加 .stop(编译成微信小程序的 catchtouchstart 后会吞掉同一个节点上的 tap,
28
+ 短按就再也删不掉、只剩长按有效),u-number-box 的加减键同样只绑 bindtouchstart。
29
+ -->
24
30
  <view
25
31
  class="u-keyboard__button-wrapper__button u-keyboard__button-wrapper__button--gray"
26
32
  hover-class="u-hover-class"
27
33
  :hover-stay-time="200"
28
34
  @tap="backspaceClick"
29
- @touchstart.stop="backspaceTouchStart"
35
+ @touchstart="backspaceTouchStart"
30
36
  @touchend="clearTimer"
37
+ @touchcancel="clearTimer"
31
38
  >
32
39
  <up-icon
33
40
  name="backspace"
@@ -115,7 +122,8 @@
115
122
  backspaceClick() {
116
123
  this.$emit('backspace');
117
124
  },
118
- // 触摸退格键,一定时间后进入长按连续删除状态,短按时会在touchend前被清除
125
+ // 触摸退格键,一定时间后进入长按连续删除状态,短按时会在touchend/touchcancel前被清除
126
+ // 不能加 .stop 修饰符:微信小程序 catchtouchstart 会阻止同一节点 tap 的派发
119
127
  backspaceTouchStart() {
120
128
  this.clearTimer(); //再次清空定时器,防止重复注册定时器
121
129
  this.timer = setTimeout(() => {
@@ -55,7 +55,8 @@
55
55
  * @property {String} icon 图标,或者绝对路径的图片
56
56
  * @property {String} type 主题类型 (默认 default)
57
57
  * @property {Boolean} show 是否显示该组件 (默认 false)
58
- * @property {Boolean} overlay 是否显示透明遮罩,防止点击穿透 (默认 true )
58
+ * @property {Boolean} overlay 是否显示透明遮罩,防止点击穿透。false 时提示期间页面可正常操作,
59
+ * 也可在 show({ overlay: false }) 中单独指定 (默认 true )
59
60
  * @property {String} position 位置 (默认 'center' )
60
61
  * @property {Object} params 跳转的参数
61
62
  * @property {String | Number} duration 展示时间,单位ms (默认 2000 )
@@ -70,6 +71,14 @@
70
71
  export default {
71
72
  name: 'u-toast',
72
73
  mixins: [mpMixin, mixin],
74
+ props: {
75
+ // 是否显示全屏透明遮罩,阻止操作页面(防止点击穿透)
76
+ // 设置为 false 时,toast 提示期间页面依然可以正常点击、滑动
77
+ overlay: {
78
+ type: Boolean,
79
+ default: true
80
+ }
81
+ },
73
82
  data() {
74
83
  return {
75
84
  isShow: false,
@@ -104,6 +113,10 @@
104
113
  return this.tmpConfig.icon
105
114
  }
106
115
  },
116
+ // 遮罩是否拦截页面操作:show() 显式传入的 overlay 优先,其次回落到组件 prop
117
+ overlayEnabled() {
118
+ return this.tmpConfig.overlay === undefined ? this.overlay : !!this.tmpConfig.overlay
119
+ },
107
120
  overlayStyle() {
108
121
  const style = {
109
122
  justifyContent: 'center',
@@ -112,10 +125,23 @@
112
125
  }
113
126
  // 将遮罩设置为100%透明度,避免出现灰色背景
114
127
  style.backgroundColor = 'rgba(0, 0, 0, 0)'
115
- // overlay=false时不阻止点击穿透
116
- if (!this.tmpConfig.overlay) {
117
- style.pointerEvents = 'none'
128
+ // 拦截模式:遮罩铺满全屏(u-overlay 默认即为全屏),提示期间阻止操作页面
129
+ if (this.overlayEnabled) {
130
+ return style
118
131
  }
132
+ // 穿透模式:让 toast 提示期间页面依然可以点击、滑动
133
+ // 1) pointer-events 让遮罩不吃事件,H5 / 小程序 / 鸿蒙均支持
134
+ style.pointerEvents = 'none'
135
+ // #ifndef APP-NVUE
136
+ // 2) 把遮罩从"铺满全屏"收缩成"跟随内容大小的浮动层",从物理上不再遮挡页面,
137
+ // 这样即便运行环境不认 pointer-events,点击与滚动也都能穿透。
138
+ // nvue(Weex) 不支持百分比 transform,故该分支只在非 nvue 端开启。
139
+ style.left = '50%'
140
+ style.top = '50%'
141
+ style.right = 'auto'
142
+ style.bottom = 'auto'
143
+ style.transform = 'translate(-50%, -50%)'
144
+ // #endif
119
145
  return style
120
146
  },
121
147
  iconStyle() {
@@ -166,7 +192,8 @@
166
192
  // 显示toast组件,由父组件通过this.$refs.xxx.show(options)形式调用
167
193
  show(options) {
168
194
  // 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
169
- this.tmpConfig = deepMerge(this.config, options)
195
+ // 组件 prop 作为 show() 未显式传值时的默认值,让 <up-toast :overlay="false"> 也能生效
196
+ this.tmpConfig = deepMerge({ ...this.config, overlay: this.overlay }, options)
170
197
  // 清除定时器
171
198
  this.clearTimer()
172
199
  this.isShow = true
@@ -14,6 +14,10 @@ export const props = defineMixin({
14
14
  type: Array,
15
15
  default: () => defProps.upload.extension
16
16
  },
17
+ mediaType: {
18
+ type: Array,
19
+ default: () => defProps.upload.mediaType
20
+ },
17
21
  // 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
18
22
  capture: {
19
23
  type: [String, Array],
@@ -223,6 +223,7 @@
223
223
  * @description 该组件用于上传图片场景
224
224
  * @tutorial https://uview-plus.jiangruyi.com/components/upload.html
225
225
  * @property {String} accept 接受的文件类型, 可选值为all media image file video (默认 'image' )
226
+ * @property {Array<String>} mediaType 当使用chooseMedia上传文件时设置的文件类型,可选值为image, video, mix,默认 ['image', 'video']
226
227
  * @property {String | Array} capture 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头(默认 ['album', 'camera'] )
227
228
  * @property {Array} extension 选择文件的后缀名,暂只支持.zip、.png等,不支持application/msword等值
228
229
  * @property {Boolean} compressed 当accept为video时生效,是否压缩视频,默认为true(默认 true )
@@ -383,7 +384,8 @@
383
384
  const chooseParams = Object.assign({
384
385
  accept: this.accept,
385
386
  extension: this.extension,
386
- multiple: this.multiple,
387
+ multiple: this.multiple,
388
+ mediaType: this.mediaType,
387
389
  capture: this.capture,
388
390
  compressed: this.compressed,
389
391
  maxDuration: this.maxDuration,
@@ -11,7 +11,8 @@ export default {
11
11
  // upload组件
12
12
  upload: {
13
13
  accept: 'image',
14
- extension: [],
14
+ extension: [],
15
+ mediaType: ['image', 'video'],
15
16
  capture: ['album', 'camera'],
16
17
  compressed: true,
17
18
  camera: 'back',
@@ -87,6 +87,7 @@ export function chooseFile({
87
87
  multiple,
88
88
  capture,
89
89
  compressed,
90
+ mediaType,
90
91
  maxDuration,
91
92
  sizeType,
92
93
  camera,
@@ -109,20 +110,28 @@ export function chooseFile({
109
110
  fail: reject
110
111
  })
111
112
  break
112
- // #ifdef MP-WEIXIN
113
- // 只有微信小程序才支持chooseMedia接口
114
113
  case 'media':
115
- wx.chooseMedia({
116
- count: multiple ? Math.min(maxCount, 9) : 1,
117
- sourceType: capture,
118
- maxDuration,
119
- sizeType,
120
- camera,
121
- success: (res) => resolve(formatMedia(res)),
122
- fail: reject
123
- })
114
+ if (wx.chooseMedia) {
115
+ wx.chooseMedia({
116
+ count: multiple ? Math.min(maxCount, 9) : 1,
117
+ mediaType,
118
+ sourceType: capture,
119
+ maxDuration,
120
+ sizeType,
121
+ camera,
122
+ success: (res) => resolve(formatMedia(res)),
123
+ fail: reject
124
+ })
125
+ } else {
126
+ uni.chooseImage({
127
+ count: multiple ? Math.min(maxCount, 9) : 1,
128
+ sourceType: capture,
129
+ sizeType,
130
+ success: (res) => resolve(formatImage(res)),
131
+ fail: reject
132
+ })
133
+ }
124
134
  break
125
- // #endif
126
135
  case 'video':
127
136
  uni.chooseVideo({
128
137
  sourceType: capture,
@@ -1,4 +1,5 @@
1
1
  // 浮点数加法
2
+ import { divide } from './digit.js'
2
3
  export function add (arg1, arg2) {
3
4
  var r1, r2, m
4
5
  try {
@@ -44,17 +45,9 @@ export function mul (a, b) {
44
45
  } catch (f) {}
45
46
  return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
46
47
  }
47
- //浮点除法
48
+ // 浮点除法
48
49
  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));
50
+ return divide(a, b);
58
51
  }
59
52
  export default {
60
53
  add,
@@ -27,8 +27,10 @@ export function createAppIconFontFeature(options = {}) {
27
27
  const rootPath = normalizePath(projectInfo.rootPath)
28
28
  const iconFontSourcePath = normalizePath(resolve(featurePath, '../../components/u-icon/upicon.ttf'))
29
29
  const appStaticIconFontPath = normalizePath(resolve(rootPath, appStaticIconFontRelativePath))
30
- const uIconUtilPath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/components/u-icon/util.js'))
31
- const uIconVuePath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/components/u-icon/u-icon.vue'))
30
+ // 同时兼容 uni_modules 与 npm(node_modules / pnpm 真实路径)两种安装方式:
31
+ // npm 安装时包位于 node_modules/uview-plus/...,按包内相对路径后缀匹配即可命中。
32
+ const isUIconUtil = (cleanId) => cleanId.endsWith('uview-plus/components/u-icon/util.js')
33
+ const isUIconVue = (cleanId) => cleanId.endsWith('uview-plus/components/u-icon/u-icon.vue')
32
34
 
33
35
  const shouldCopyFile = (sourcePath, targetPath) => {
34
36
  if (!existsSync(targetPath)) return true
@@ -55,15 +57,15 @@ export function createAppIconFontFeature(options = {}) {
55
57
  if (!isAppPlatform()) return null
56
58
  const cleanId = toCleanId(id)
57
59
  if (!enabled) {
58
- if (cleanId === uIconUtilPath && code.includes(appStaticIconFontFlag)) {
60
+ if (isUIconUtil(cleanId) && code.includes(appStaticIconFontFlag)) {
59
61
  return code.replace(appStaticIconFontFlag, appStaticIconFontDisabledFlag)
60
62
  }
61
63
  return null
62
64
  }
63
- if (cleanId === uIconVuePath && appRemoteIconFontCondition.test(code)) {
65
+ if (isUIconVue(cleanId) && appRemoteIconFontCondition.test(code)) {
64
66
  return code.replace(appRemoteIconFontCondition, '/* #ifdef $1 */')
65
67
  }
66
- if (cleanId === uIconVuePath && appCompiledRemoteIconFontFace.test(code)) {
68
+ if (isUIconVue(cleanId) && appCompiledRemoteIconFontFace.test(code)) {
67
69
  return removeAppCompiledRemoteIconFontFace(code)
68
70
  }
69
71
  return null
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.8.130",
5
+ "version": "3.8.136",
6
6
  "description": "零云®uview-plus已兼容vue3支持多语言,120+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
7
7
  "keywords": [
8
8
  "uview",
@@ -10,6 +10,11 @@ declare interface ToastProps {
10
10
  * @default false
11
11
  */
12
12
  loading?: boolean
13
+ /**
14
+ * 是否显示全屏透明遮罩,阻止操作页面(防止点击穿透)
15
+ * @default true
16
+ */
17
+ overlay?: boolean
13
18
  /**
14
19
  * 显示的文本
15
20
  */
@@ -34,6 +34,8 @@ declare interface UploadProps {
34
34
  * @default "image"
35
35
  */
36
36
  accept?: 'all' | 'media' | 'image' | 'file' | 'video'
37
+ /** 当使用chooseMedia上传文件时设置的文件类型,可选值为image, video, mix,默认 ['image', 'video'] */
38
+ mediaType?: ('image' | 'video' | 'mix')[]
37
39
  /**
38
40
  * 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
39
41
  * @default ["album", "camera"]