emacroh5lib 1.0.28 → 1.0.31

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.28",
3
+ "version": "1.0.31",
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": [
@@ -106,4 +106,4 @@
106
106
  "xlsx": "^0.18.5",
107
107
  "xlsx-style": "^0.8.13"
108
108
  }
109
- }
109
+ }
@@ -6,7 +6,7 @@ import createTaskQueue from 'sync-task-queue'
6
6
 
7
7
  export namespace EMacro {
8
8
 
9
- export const version = "1.0"
9
+ export const version = "1.1"
10
10
 
11
11
  export class File {
12
12
 
@@ -59,9 +59,7 @@ export namespace EMacro {
59
59
  }
60
60
 
61
61
  // 文件上传
62
- public static uploadFiles(files, postFunc, chunkSize: number = 1024 * 1024 * 1, errFunc = (err) => {
63
- console.error(err);
64
- }) {
62
+ public static async uploadFiles(files, chunkFileHandle, fileComplete = (file) => { }, completeHandle = (files) => { }, chunkSize: number = 1024 * 1024 * 1) {
65
63
 
66
64
  if (files[0].fileName == "" || files[0].fileSize == "" || files[0].fileSize == 0) {
67
65
  throw new Error("文件异常")
@@ -69,41 +67,31 @@ export namespace EMacro {
69
67
 
70
68
  for (let i = 0; i < files.length; i++) {
71
69
  const file = files[i];
72
- let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
73
-
74
- File.getFileMD5(file).then(md5 => {
75
-
76
- const taskQueue = createTaskQueue();
77
-
78
- for (let index in fileChunks) {
79
- let chunk = fileChunks[Number(index)]
70
+ const md5 = await File.getFileMD5(file)
80
71
 
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));
72
+ let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file, chunkSize)
96
73
 
97
- }).catch((err) => {
98
- errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.name })
99
- })
74
+ for (let index in fileChunks) {
75
+ let chunk = fileChunks[Number(index)]
76
+ const base64 = await File.getBase64(chunk) as string
77
+ let chunkFile = {
78
+ 'chunkIndex': Number(index), // 分片位置
79
+ 'chunksLength': chunksLength, // 分片长度
80
+ 'sliceSize': sliceSize, // 分片大小
81
+ 'chunkSize': chunk.size, // 当前分片实际大小
82
+ 'fileSize': file.size, // 文件总大小
83
+ 'fileName': file.name, // 文件名
84
+ 'data': base64.split(';base64,')[1], // 文件数据
85
+ 'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
86
+ 'md5': md5,
87
+ 'index': i,
88
+ 'dataType': 'base64' // 数据的类型
100
89
  }
101
-
102
- }).catch(err => {
103
- throw err
104
- })
105
-
90
+ await chunkFileHandle(chunkFile)
91
+ }
92
+ fileComplete(file);
106
93
  }
94
+ completeHandle(files)
107
95
  }
108
96
 
109
97
  public static selectFile(options: any = { multiple: true, accept: "*/*" }): Promise<FileList | null> {
@@ -149,6 +137,23 @@ export namespace EMacro {
149
137
 
150
138
  }
151
139
 
140
+ export const fullScreen = (docElm: any = null) => {
141
+ if (docElm === null) {
142
+ docElm = document.documentElement
143
+ }
144
+ if (docElm.requestFullscreen) {
145
+ docElm.requestFullscreen();
146
+ } else if (docElm.mozRequestFullScreen) {
147
+ docElm.mozRequestFullScreen();
148
+ } else if (docElm.msRequestFullscreen) {
149
+ docElm.msRequestFullscreen();
150
+ } else if (docElm.oRequestFullscreen) {
151
+ docElm.oRequestFullscreen();
152
+ } else if (docElm.webkitRequestFullScreen) {
153
+ docElm.webkitRequestFullScreen();
154
+ }
155
+ }
156
+
152
157
  }
153
158
 
154
159
 
@@ -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
 
@@ -10,8 +10,6 @@
10
10
  :currentIndex="currentIndex" />
11
11
 
12
12
 
13
-
14
-
15
13
  <div class="list" id="list">
16
14
 
17
15
  <DragResizeView v-for="(rect, index) in rects" :key="index" :isStorage="true" :name="rect.name" :w="rect.width"