sadais-piui 1.2.7-beta139 → 1.2.7-beta140

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.
@@ -404,6 +404,13 @@ export default {
404
404
  default() {
405
405
  return uploadImg.fileIconMap
406
406
  }
407
+ },
408
+ // 自定义上传参数,对象形式
409
+ customUploadParams: {
410
+ type: Object,
411
+ default() {
412
+ return uploadImg.customUploadParams
413
+ }
407
414
  }
408
415
  },
409
416
  data() {
@@ -670,7 +677,10 @@ export default {
670
677
  let beforeUploadResult = true
671
678
  if (this.$pi.lang.isFunction(beforeUpload)) {
672
679
  console.log(TAG, '调用文件上传前钩子')
673
- beforeUploadResult = await beforeUpload(file)
680
+ beforeUploadResult = await beforeUpload(
681
+ file,
682
+ this.customUploadParams
683
+ )
674
684
  }
675
685
  if (!beforeUploadResult) {
676
686
  console.log(TAG, '文件上传前钩子返回false,跳过上传')
@@ -690,7 +700,7 @@ export default {
690
700
  if (this.$pi.lang.isFunction(onProgress)) {
691
701
  console.log(TAG, '使用自定义上传函数')
692
702
  // 上传之前的钩子, 如果定义了则使用钩子上传文件
693
- uploadResult = await onProgress(params)
703
+ uploadResult = await onProgress(params, this.customUploadParams)
694
704
  } else {
695
705
  const [, uploadFileResult] = await uni.uploadFile(params)
696
706
  uploadResult = uploadFileResult
@@ -699,7 +709,10 @@ export default {
699
709
 
700
710
  // ---------- 解析上传结果 ----------
701
711
  this.$emit('uploaded', uploadResult)
702
- const item = await parseResultFn(uploadResult)
712
+ const item = await parseResultFn(
713
+ uploadResult,
714
+ this.customUploadParams
715
+ )
703
716
  if (item) {
704
717
  this.isValString ? (this.val = item) : this.val.push(item)
705
718
  this.handleEmitChange()
@@ -78,5 +78,6 @@ export default {
78
78
  beforeUpload: null, // 上传之前的钩子
79
79
  onProgress: null, // 文件上传时的钩子
80
80
  beforeRemove: null, // 删除之前的钩子
81
- fileIconMap: {} // 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
81
+ fileIconMap: {}, // 文件类型和图标映射关系,对象形式({PDF: 'https://xxx'})
82
+ customUploadParams: {} // 自定义上传参数,对象形式
82
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta139",
3
+ "version": "1.2.7-beta140",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {