emacroh5lib 1.0.27 → 1.0.30

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.27",
3
+ "version": "1.0.30",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -14,7 +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
+ "push": "npm run build && npm publish --registry https://registry.npmjs.org",
18
18
  "test": "echo \"Error: no test specified\" && exit 1"
19
19
  },
20
20
  "keywords": [
@@ -93,6 +93,7 @@
93
93
  "lay-excel": "^1.7.6",
94
94
  "query-string": "^7.0.1",
95
95
  "register-service-worker": "^1.7.2",
96
+ "sync-task-queue": "^1.0.4",
96
97
  "three": "^0.139.2",
97
98
  "types": "file:../../browser-md5-file",
98
99
  "typings": "^2.1.1",
@@ -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"
@@ -57,7 +59,7 @@ export namespace EMacro {
57
59
  }
58
60
 
59
61
  // 文件上传
60
- public static uploadFiles(files, postFunc, chunkSize: number = 1024 * 1024 * 1, errFunc = (err) => {
62
+ public static async uploadFiles(files, postFunc, chunkSize: number = 1024 * 1024 * 1, errFunc = (err) => {
61
63
  console.error(err);
62
64
  }) {
63
65
 
@@ -67,40 +69,27 @@ export namespace EMacro {
67
69
 
68
70
  for (let i = 0; i < files.length; i++) {
69
71
  const file = files[i];
70
- let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
71
-
72
- File.getFileMD5(file).then(md5 => {
73
-
74
- for (let index in fileChunks) {
75
- let chunk = fileChunks[Number(index)]
76
-
77
- File.getBase64(chunk).then((base64: any) => {
78
- let data = {
79
- 'chunkIndex': Number(index), // 分片位置
80
- 'chunksLength': chunksLength, // 分片长度
81
- 'sliceSize': sliceSize, // 分片大小
82
- 'chunkSize': chunk.size, // 当前分片实际大小
83
- 'fileSize': file.size, // 文件总大小
84
- 'fileName': file.name, // 文件名
85
- 'data': base64.split(';base64,')[1], // 文件数据
86
- 'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
87
- 'md5': md5,
88
- 'dataType': 'base64' // 数据的类型
89
- }
90
- setTimeout(async () => {
91
- await postFunc(data)
92
- }, 10 * Number(index));
93
-
94
- }).catch((err) => {
95
- errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.name })
96
- })
72
+ const md5 = await File.getFileMD5(file)
97
73
 
74
+ let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
98
75
 
76
+ for (let index in fileChunks) {
77
+ let chunk = fileChunks[Number(index)]
78
+ const base64 = await File.getBase64(chunk) as string
79
+ let data = {
80
+ 'chunkIndex': Number(index), // 分片位置
81
+ 'chunksLength': chunksLength, // 分片长度
82
+ 'sliceSize': sliceSize, // 分片大小
83
+ 'chunkSize': chunk.size, // 当前分片实际大小
84
+ 'fileSize': file.size, // 文件总大小
85
+ 'fileName': file.name, // 文件名
86
+ 'data': base64.split(';base64,')[1], // 文件数据
87
+ 'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
88
+ 'md5': md5,
89
+ 'dataType': 'base64' // 数据的类型
99
90
  }
100
-
101
- }).catch(err => {
102
- throw err
103
- })
91
+ await postFunc(data)
92
+ }
104
93
 
105
94
  }
106
95
  }
@@ -4,7 +4,7 @@
4
4
  <img ref="duoViewerImage" :src="realSrc" alt="image" class="duo-viewer-mask__image" />
5
5
  </div>
6
6
  <div class="duo-viewer-footer">
7
- <div class="duo-viewer-footer__title">{{ realSrc }}</div>
7
+ <div class="duo-viewer-footer__title">{{ realName }}</div>
8
8
  <div class="duo-viewer-footer__toolbar">
9
9
  <ul>
10
10
  <li class="duo-viewer-footer__zoom-in" data-viewer-action="zoom-in"></li>
@@ -71,6 +71,18 @@
71
71
  type: Number,
72
72
  default: 0,
73
73
  },
74
+ name: {
75
+ type: [String, Array],
76
+ default: null,
77
+ },
78
+ shrink: {
79
+ type: Number,
80
+ default: .4,
81
+ },
82
+ enlarge: {
83
+ type: Number,
84
+ default: .6,
85
+ }
74
86
  },
75
87
  computed: {
76
88
  listLength() {
@@ -79,6 +91,17 @@
79
91
  realSrc() {
80
92
  return this.list[this.index];
81
93
  },
94
+ realName() {
95
+ if (this.name == null) {
96
+ return this.list[this.index];
97
+ } else if (typeof this.name == "string") {
98
+ return this.name
99
+ } else if (Array.isArray(this.name)) {
100
+ return this.name[this.index];
101
+ } else {
102
+ return "未命名"
103
+ }
104
+ },
82
105
  currentData() {
83
106
  return this.listDataCache[this.index];
84
107
  },
@@ -312,11 +335,11 @@
312
335
  if (h <= 20 && type === "out") return;
313
336
 
314
337
  if (type === "out") {
315
- this.setStyleByName(image, "width", `${w * 0.45}px`);
316
- this.setStyleByName(image, "height", `${h * 0.45}px`);
338
+ this.setStyleByName(image, "width", `${w * this.shrink}px`);
339
+ this.setStyleByName(image, "height", `${h * this.shrink}px`);
317
340
  } else {
318
- this.setStyleByName(image, "width", `${w * (1 + 0.35)}px`);
319
- this.setStyleByName(image, "height", `${h * (1 + 0.35)}px`);
341
+ this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
342
+ this.setStyleByName(image, "height", `${h * (1 + this.enlarge)}px`);
320
343
  }
321
344
 
322
345
  this.currentData.width = this.getStyleByName(this.image, "width");
@@ -362,6 +385,10 @@
362
385
  // up
363
386
  this.zoom("in");
364
387
  }
388
+ if (e && e.keyCode == 27) {
389
+ // esc
390
+ this.handleClose()
391
+ }
365
392
  });
366
393
  },
367
394