emacroh5lib 1.0.72 → 1.0.75

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.75",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -71,6 +71,15 @@ export namespace EMacro {
71
71
 
72
72
  let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
73
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
+
74
83
  for (let index in fileChunks) {
75
84
  let chunk = fileChunks[Number(index)]
76
85
  const base64 = await File.getBase64(chunk) as string
@@ -85,7 +94,8 @@ export namespace EMacro {
85
94
  'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
86
95
  'md5': md5,
87
96
  'index': i,
88
- 'dataType': 'base64' // 数据的类型
97
+ 'dataType': 'base64', // 数据的类型
98
+ 'directoryName': directoryName // 数据的类型
89
99
  }
90
100
  await chunkFileHandle(chunkFile)
91
101
  }
@@ -94,16 +104,17 @@ export namespace EMacro {
94
104
  completeHandle(files)
95
105
  }
96
106
 
97
- public static selectFile(options: any = { multiple: true, accept: "*/*" }): Promise<FileList | null> {
107
+ public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = false): Promise<FileList | null> {
98
108
  return new Promise((res: (value: FileList) => void, rej) => {
99
109
  const el = document.createElement("input");
100
110
  el.type = "file";
101
111
  el.accept = options.accept;
112
+ el.webkitdirectory = isDirectory;
102
113
  el.multiple = options.multiple;
103
114
  el.addEventListener("change", (_) => {
104
115
  try {
105
116
  if (el.files === null) {
106
- rej(null)
117
+ rej(null);
107
118
  } else {
108
119
  res(el.files);
109
120
  }