emacroh5lib 1.0.73 → 1.0.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacroh5lib",
3
- "version": "1.0.73",
3
+ "version": "1.0.77",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -64,23 +64,22 @@ export namespace EMacro {
64
64
  if (files[0].fileName == "" || files[0].fileSize == "" || files[0].fileSize == 0) {
65
65
  throw new Error("文件异常")
66
66
  }
67
- let directoryName = "";
68
- if (files[0].webkitRelativePath != null && files[0].webkitRelativePath.trim() != "" ) {
69
- let n = files[0].webkitRelativePath.indexOf("\\")
70
- if (n == -1 ) {
71
- n = files[0].webkitRelativePath.indexOf("/")
72
- }
73
- if (n != -1) {
74
- directoryName = files[0].webkitRelativePath.substring(0, n)
75
- }
76
- }
77
67
 
78
68
  for (let i = 0; i < files.length; i++) {
79
69
  const file = files[i];
80
70
  const md5 = await File.getFileMD5(file)
81
-
71
+
82
72
  let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
83
73
 
74
+ let directoryName = "";
75
+ if (files[i].webkitRelativePath != null && files[i].webkitRelativePath.trim() != "") {
76
+ let n = files[i].webkitRelativePath.lastIndexOf("\\")
77
+ if (n == -1)
78
+ n = files[i].webkitRelativePath.lastIndexOf("/")
79
+ if (n != -1)
80
+ directoryName = files[i].webkitRelativePath.substring(0, n)
81
+ }
82
+
84
83
  for (let index in fileChunks) {
85
84
  let chunk = fileChunks[Number(index)]
86
85
  const base64 = await File.getBase64(chunk) as string
@@ -91,12 +90,13 @@ export namespace EMacro {
91
90
  'chunkSize': chunk.size, // 当前分片实际大小
92
91
  'fileSize': file.size, // 文件总大小
93
92
  'fileName': file.name, // 文件名
94
- 'data': base64.split(';base64,')[1], // 文件数据
95
93
  'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
96
94
  'md5': md5,
97
95
  'index': i,
98
96
  'dataType': 'base64', // 数据的类型
99
- 'directoryName': directoryName // 数据的类型
97
+ 'directoryName': directoryName, // 数据的类型
98
+ 'total': files.length, // 总共文件数
99
+ 'data': base64.split(';base64,')[1], // 文件数据
100
100
  }
101
101
  await chunkFileHandle(chunkFile)
102
102
  }
@@ -105,7 +105,7 @@ export namespace EMacro {
105
105
  completeHandle(files)
106
106
  }
107
107
 
108
- public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = false): Promise<FileList | null> {
108
+ public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = true): Promise<FileList | null> {
109
109
  return new Promise((res: (value: FileList) => void, rej) => {
110
110
  const el = document.createElement("input");
111
111
  el.type = "file";
@@ -115,7 +115,7 @@ export namespace EMacro {
115
115
  el.addEventListener("change", (_) => {
116
116
  try {
117
117
  if (el.files === null) {
118
- rej(null)
118
+ rej(null);
119
119
  } else {
120
120
  res(el.files);
121
121
  }