@idooel/components 0.0.2-beta.5 → 0.0.2-beta.7
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/dist/@idooel/components.esm.js +798 -335
- package/dist/@idooel/components.umd.js +798 -335
- package/package.json +1 -1
- package/packages/upload/src/index.vue +32 -8
package/package.json
CHANGED
|
@@ -164,8 +164,7 @@ export default {
|
|
|
164
164
|
querys: {
|
|
165
165
|
type: Object,
|
|
166
166
|
default: () => ({
|
|
167
|
-
_csrf: localStorage.getItem('token')
|
|
168
|
-
_t: new Date().valueOf()
|
|
167
|
+
_csrf: localStorage.getItem('token')
|
|
169
168
|
})
|
|
170
169
|
},
|
|
171
170
|
headers: {
|
|
@@ -192,7 +191,8 @@ export default {
|
|
|
192
191
|
// 上传状态管理
|
|
193
192
|
saveToServerAsyncPageTimer: null,
|
|
194
193
|
uploadRefId: null,
|
|
195
|
-
groupId
|
|
194
|
+
// 多选且外部无值时,预先生成 groupId,确保首次上传参数完整
|
|
195
|
+
groupId: (this.multiple && !this.value) ? uuidv4() : null
|
|
196
196
|
}
|
|
197
197
|
},
|
|
198
198
|
created() {
|
|
@@ -205,8 +205,6 @@ export default {
|
|
|
205
205
|
watch: {
|
|
206
206
|
value: {
|
|
207
207
|
async handler(value) {
|
|
208
|
-
console.log('watch.value triggered:', { value, multiple: this.multiple, currentGroupId: this.groupId })
|
|
209
|
-
|
|
210
208
|
if (type.isEmpty(value)) {
|
|
211
209
|
this.resetFiles()
|
|
212
210
|
} else if (this.multiple) {
|
|
@@ -591,10 +589,27 @@ export default {
|
|
|
591
589
|
this.activateUploadComponent(newFile, oldFile)
|
|
592
590
|
},
|
|
593
591
|
|
|
592
|
+
/**
|
|
593
|
+
* 生成唯一的随机数
|
|
594
|
+
*/
|
|
595
|
+
generateUniqueRandom() {
|
|
596
|
+
// 使用 crypto.getRandomValues 生成更安全的随机数
|
|
597
|
+
if (window.crypto && window.crypto.getRandomValues) {
|
|
598
|
+
const array = new Uint32Array(1)
|
|
599
|
+
window.crypto.getRandomValues(array)
|
|
600
|
+
return array[0].toString()
|
|
601
|
+
}
|
|
602
|
+
// 降级方案:使用 Math.random 结合时间戳
|
|
603
|
+
return Math.random().toString(36).substr(2, 9) + Date.now().toString(36)
|
|
604
|
+
},
|
|
605
|
+
|
|
594
606
|
/**
|
|
595
607
|
* 处理文件添加
|
|
596
608
|
*/
|
|
597
609
|
handleFileAdd(newFile) {
|
|
610
|
+
// 为每个文件生成唯一的随机数
|
|
611
|
+
const uniqueRandom = this.generateUniqueRandom()
|
|
612
|
+
newFile.postAction = newFile.postAction + '&_t=' + uniqueRandom
|
|
598
613
|
console.log('add file:', newFile)
|
|
599
614
|
console.log('extensions:', this.extensions)
|
|
600
615
|
console.log('accept:', this.accept)
|
|
@@ -607,7 +622,6 @@ export default {
|
|
|
607
622
|
this.removeInvalidFile(newFile)
|
|
608
623
|
return
|
|
609
624
|
}
|
|
610
|
-
|
|
611
625
|
console.log('文件类型验证通过,继续上传')
|
|
612
626
|
},
|
|
613
627
|
|
|
@@ -698,8 +712,18 @@ export default {
|
|
|
698
712
|
resetFiles() {
|
|
699
713
|
this.files = []
|
|
700
714
|
this.buildedFiles = []
|
|
701
|
-
|
|
702
|
-
|
|
715
|
+
// 多选模式下保留或生成 groupId,避免首次上传为空
|
|
716
|
+
if (this.multiple) {
|
|
717
|
+
if (!this.groupId) {
|
|
718
|
+
this.groupId = uuidv4()
|
|
719
|
+
console.log('Generated groupId in resetFiles:', this.groupId)
|
|
720
|
+
} else {
|
|
721
|
+
console.log('Preserve existing groupId in resetFiles:', this.groupId)
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
this.groupId = null
|
|
725
|
+
console.log('Reset groupId to null (single mode)')
|
|
726
|
+
}
|
|
703
727
|
},
|
|
704
728
|
|
|
705
729
|
/**
|