emacroh5lib 1.0.72 → 1.0.73

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.72",
3
+ "version": "1.0.73",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -64,11 +64,21 @@ 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
+ }
67
77
 
68
78
  for (let i = 0; i < files.length; i++) {
69
79
  const file = files[i];
70
80
  const md5 = await File.getFileMD5(file)
71
-
81
+
72
82
  let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
73
83
 
74
84
  for (let index in fileChunks) {
@@ -85,7 +95,8 @@ export namespace EMacro {
85
95
  'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
86
96
  'md5': md5,
87
97
  'index': i,
88
- 'dataType': 'base64' // 数据的类型
98
+ 'dataType': 'base64', // 数据的类型
99
+ 'directoryName': directoryName // 数据的类型
89
100
  }
90
101
  await chunkFileHandle(chunkFile)
91
102
  }
@@ -94,11 +105,12 @@ export namespace EMacro {
94
105
  completeHandle(files)
95
106
  }
96
107
 
97
- public static selectFile(options: any = { multiple: true, accept: "*/*" }): Promise<FileList | null> {
108
+ public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = false): Promise<FileList | null> {
98
109
  return new Promise((res: (value: FileList) => void, rej) => {
99
110
  const el = document.createElement("input");
100
111
  el.type = "file";
101
112
  el.accept = options.accept;
113
+ el.webkitdirectory = isDirectory;
102
114
  el.multiple = options.multiple;
103
115
  el.addEventListener("change", (_) => {
104
116
  try {