emacroh5lib 1.0.25 → 1.0.28
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/emacroh5lib.min.js +1 -1
- package/package.json +3 -1
- package/src/utilities/File.ts +23 -19
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "emacroh5lib",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.28",
|
4
4
|
"description": "EMacro前端组件库",
|
5
5
|
"main": "dist/emacroh5lib.min.js",
|
6
6
|
"scripts": {
|
@@ -14,6 +14,7 @@
|
|
14
14
|
"serve": "webpack serve",
|
15
15
|
"dev": "vue-cli-service test:e2e",
|
16
16
|
"commit": "cz",
|
17
|
+
"push": "webpack --mode=production --node-env=production && npm publish --registry https://registry.npmjs.org",
|
17
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
18
19
|
},
|
19
20
|
"keywords": [
|
@@ -92,6 +93,7 @@
|
|
92
93
|
"lay-excel": "^1.7.6",
|
93
94
|
"query-string": "^7.0.1",
|
94
95
|
"register-service-worker": "^1.7.2",
|
96
|
+
"sync-task-queue": "^1.0.4",
|
95
97
|
"three": "^0.139.2",
|
96
98
|
"types": "file:../../browser-md5-file",
|
97
99
|
"typings": "^2.1.1",
|
package/src/utilities/File.ts
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
import * as XLSX from "xlsx";
|
3
3
|
import BMF from 'browser-md5-file';
|
4
4
|
|
5
|
+
import createTaskQueue from 'sync-task-queue'
|
6
|
+
|
5
7
|
export namespace EMacro {
|
6
8
|
|
7
9
|
export const version = "1.0"
|
@@ -71,28 +73,30 @@ export namespace EMacro {
|
|
71
73
|
|
72
74
|
File.getFileMD5(file).then(md5 => {
|
73
75
|
|
76
|
+
const taskQueue = createTaskQueue();
|
77
|
+
|
74
78
|
for (let index in fileChunks) {
|
75
79
|
let chunk = fileChunks[Number(index)]
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
})
|
95
|
-
}
|
81
|
+
File.getBase64(chunk).then((base64: any) => {
|
82
|
+
let data = {
|
83
|
+
'chunkIndex': Number(index), // 分片位置
|
84
|
+
'chunksLength': chunksLength, // 分片长度
|
85
|
+
'sliceSize': sliceSize, // 分片大小
|
86
|
+
'chunkSize': chunk.size, // 当前分片实际大小
|
87
|
+
'fileSize': file.size, // 文件总大小
|
88
|
+
'fileName': file.name, // 文件名
|
89
|
+
'data': base64.split(';base64,')[1], // 文件数据
|
90
|
+
'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
|
91
|
+
'md5': md5,
|
92
|
+
'dataType': 'base64' // 数据的类型
|
93
|
+
}
|
94
|
+
|
95
|
+
taskQueue.enqueue(postFunc(data)).then((res) => console.log('文件上传chunkIndex: ', index, res));
|
96
|
+
|
97
|
+
}).catch((err) => {
|
98
|
+
errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.name })
|
99
|
+
})
|
96
100
|
}
|
97
101
|
|
98
102
|
}).catch(err => {
|