mali-applet-ui 1.1.102 → 1.1.104

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.
@@ -63,7 +63,7 @@
63
63
  <view class="ml-upload-file-info">
64
64
  <view class="ml-upload-file-name">{{ item[nameField] }}</view>
65
65
  <view class="ml-upload-file-desc">
66
- <ml-button v-if="preview && previewTypes.includes(item[typeField])" status="primary" type="text" size="small" @click="previewDocs(item)">预览</ml-button>
66
+ <ml-button v-if="preview && hasPreviewType(item)" status="primary" type="text" size="small" @click="previewDocs(item)">预览</ml-button>
67
67
  <ml-button status="primary" type="text" size="small" @click="downloadEvent(item)">下载</ml-button>
68
68
  </view>
69
69
  </view>
@@ -85,7 +85,7 @@
85
85
  <view class="ml-upload-file-info">
86
86
  <view class="ml-upload-file-name">{{ item[nameField] }}</view>
87
87
  <view class="ml-upload-file-desc">
88
- <ml-button v-if="preview && previewTypes.includes(item[typeField])" status="primary" type="text" size="small" @click="previewDocs(item)">预览</ml-button>
88
+ <ml-button v-if="preview && hasPreviewType(item)" status="primary" type="text" size="small" @click="previewDocs(item)">预览</ml-button>
89
89
  <ml-button status="primary" type="text" size="small" @click="downloadEvent(item)">下载</ml-button>
90
90
  </view>
91
91
  </view>
@@ -225,7 +225,7 @@ export default {
225
225
  },
226
226
  limitSize: {
227
227
  type: Number,
228
- default: Number(globalStore.upload?.limitSize || 204800) // KB
228
+ default: Number(globalStore.upload?.limitSize || 512000) // KB
229
229
  },
230
230
  className: String,
231
231
  mediatype: {
@@ -275,21 +275,10 @@ export default {
275
275
  return {
276
276
  loading: false,
277
277
  fileList: [],
278
- docsTypes: ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'],
279
- imgTypes: ['jpg', 'jpeg', 'png', 'gif'],
280
278
  platformEnv: MaliUtils.getPlatformEnv()
281
279
  }
282
280
  },
283
281
  computed: {
284
- fileTypes () {
285
- if (this.types && this.types.length) {
286
- return this.types
287
- }
288
- if (this.mediatype === 'image') {
289
- return this.imgTypes
290
- }
291
- return []
292
- },
293
282
  fileGroup () {
294
283
  return {
295
284
  imgData: this.fileList ? this.fileList.filter(item => this.hasImageType(item)) : [],
@@ -320,11 +309,8 @@ export default {
320
309
  }
321
310
  return this.form ? this.form.readonly : false
322
311
  },
323
- previewTypes () {
324
- return this.docsTypes.concat(this.imgTypes)
325
- },
326
312
  imageList () {
327
- return this.fileList ? this.fileList.filter(item => this.imgTypes.includes(item[this.typeField])) : []
313
+ return this.fileList ? this.fileList.filter(item => this.hasImageType(item)) : []
328
314
  },
329
315
  fieldMaps () {
330
316
  return { ...globalStore.upload.fileProps, ...this.fileProps }
@@ -409,9 +395,6 @@ export default {
409
395
  this.$emit('input', value)
410
396
  this.$emit('change', { value })
411
397
  },
412
- hasImageType (item) {
413
- return this.imgTypes.includes(XEUtils.toValueString(item[this.typeField]).toLowerCase())
414
- },
415
398
  removeEvent (item) {
416
399
  this.fileList = this.fileList.filter(obj => obj[this.urlField] !== item[this.urlField])
417
400
  const removeMethod = this.removeFile ? this.removeFile : (globalStore.upload ? globalStore.upload.removeFile : null)
@@ -449,6 +432,18 @@ export default {
449
432
  }
450
433
  return item[this.urlField]
451
434
  },
435
+ hasDocType (item) {
436
+ return MaliUtils.hasFilePreviewType(item[this.typeField])
437
+ },
438
+ hasVideoType (item) {
439
+ return MaliUtils.hasVideoPreviewType(item[this.typeField])
440
+ },
441
+ hasImageType (item) {
442
+ return MaliUtils.hasImagePreviewType(item[this.typeField])
443
+ },
444
+ hasPreviewType (item) {
445
+ return this.hasImageType(item) || this.hasDocType(item) || this.hasVideoType(item)
446
+ },
452
447
  previewImageEvent (item) {
453
448
  if (!this.preview) {
454
449
  return
@@ -511,16 +506,17 @@ export default {
511
506
  if (previewMethod) {
512
507
  previewMethod({
513
508
  item,
509
+ items: this.imageList,
514
510
  params: this.params
515
511
  })
516
512
  return
517
513
  }
518
514
  // 仅支持文档和图片
519
- if (this.previewTypes.includes(item[this.typeField])) {
515
+ if (this.hasDocType(item) || this.hasImageType(item)) {
520
516
  uni.downloadFile({
521
517
  url: this.getUrl(item),
522
518
  success: (downRes) => {
523
- if (this.docsTypes.includes(item[this.typeField])) {
519
+ if (this.hasDocType(item)) {
524
520
  uni.openDocument({
525
521
  filePath: downRes.tempFilePath,
526
522
  showMenu: true,
@@ -532,7 +528,7 @@ export default {
532
528
  })
533
529
  }
534
530
  })
535
- } else if (this.imgTypes.includes(item[this.typeField])) {
531
+ } else if (this.hasImageType(item)) {
536
532
  this.previewImg(item)
537
533
  }
538
534
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.1.102",
3
+ "version": "1.1.104",
4
4
  "description": "码里UI-小程序组件库(vue2)",
5
5
  "files": [
6
6
  "lib",