emacroh5lib 1.0.16 → 1.0.20
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/dist/emacroh5lib.min.js +1 -1
- package/dist/main.css +0 -72
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/utilities/File.ts +76 -4
- package/src/views/{DragResizeViewTs → DragResizeView}/index.less +1 -8
- package/src/views/DragResizeView/index.vue +955 -3
- package/src/views/DragResizeViewJs/index.vue +3 -0
- package/src/views/{DragResizeView → DragResizeViewJs}/vue-drag-resize.css +0 -0
- package/src/views/{DragResizeView → DragResizeViewJs}/vue-drag-resize.html +0 -0
- package/src/views/{DragResizeView → DragResizeViewJs}/vue-drag-resize.js +0 -0
- package/src/views/Draw/index.less +98 -0
- package/src/views/Draw/index.vue +429 -0
- package/src/views/TestView/index.less +10 -0
- package/src/views/TestView/index.vue +11 -6
- package/tsconfig.json +1 -1
- package/webpack.config.js +3 -1
- package/src/views/DragResizeViewTs/index.vue +0 -917
- package/src/views/DragResizeViewTs/vue-drag-resize.css +0 -46
- package/src/views/DragResizeViewTs/vue-drag-resize.html +0 -17
- package/src/views/DragResizeViewTs/vue-drag-resize.ts +0 -876
package/dist/main.css
CHANGED
@@ -1,18 +1,3 @@
|
|
1
|
-
.app-container[data-v-7a6f68ae] {
|
2
|
-
height: 100%;
|
3
|
-
width: 100%;
|
4
|
-
margin: 0;
|
5
|
-
padding: 0;
|
6
|
-
background-color: aqua;
|
7
|
-
}
|
8
|
-
.click-button[data-v-7a6f68ae] {
|
9
|
-
padding: 10px;
|
10
|
-
font-size: 16px;
|
11
|
-
color: white;
|
12
|
-
border-radius: 15px;
|
13
|
-
background-color: blue;
|
14
|
-
}
|
15
|
-
|
16
1
|
.duo-viewer {
|
17
2
|
position: fixed;
|
18
3
|
top: 0;
|
@@ -199,60 +184,3 @@
|
|
199
184
|
border-radius: 0.15em;
|
200
185
|
}
|
201
186
|
|
202
|
-
.app-container[data-v-ab09ceac] {
|
203
|
-
height: 100%;
|
204
|
-
width: 100%;
|
205
|
-
margin: 0;
|
206
|
-
padding: 0;
|
207
|
-
}
|
208
|
-
.vdr[data-v-ab09ceac] {
|
209
|
-
position: absolute;
|
210
|
-
box-sizing: border-box;
|
211
|
-
}
|
212
|
-
.vdr.active[data-v-ab09ceac]:before {
|
213
|
-
content: '';
|
214
|
-
width: 100%;
|
215
|
-
height: 100%;
|
216
|
-
position: absolute;
|
217
|
-
top: 0;
|
218
|
-
left: 0;
|
219
|
-
box-sizing: border-box;
|
220
|
-
outline: 1px dashed #d6d6d6;
|
221
|
-
}
|
222
|
-
.vdr-stick[data-v-ab09ceac] {
|
223
|
-
box-sizing: border-box;
|
224
|
-
position: absolute;
|
225
|
-
font-size: 1px;
|
226
|
-
background: #ffffff;
|
227
|
-
border: 1px solid #6c6c6c;
|
228
|
-
box-shadow: 0 0 2px #bbb;
|
229
|
-
}
|
230
|
-
.inactive .vdr-stick[data-v-ab09ceac] {
|
231
|
-
display: none;
|
232
|
-
}
|
233
|
-
.vdr-stick-tl[data-v-ab09ceac],
|
234
|
-
.vdr-stick-br[data-v-ab09ceac] {
|
235
|
-
cursor: nwse-resize;
|
236
|
-
}
|
237
|
-
.vdr-stick-tm[data-v-ab09ceac],
|
238
|
-
.vdr-stick-bm[data-v-ab09ceac] {
|
239
|
-
left: 50%;
|
240
|
-
cursor: ns-resize;
|
241
|
-
}
|
242
|
-
.vdr-stick-tr[data-v-ab09ceac],
|
243
|
-
.vdr-stick-bl[data-v-ab09ceac] {
|
244
|
-
cursor: nesw-resize;
|
245
|
-
}
|
246
|
-
.vdr-stick-ml[data-v-ab09ceac],
|
247
|
-
.vdr-stick-mr[data-v-ab09ceac] {
|
248
|
-
top: 50%;
|
249
|
-
cursor: ew-resize;
|
250
|
-
}
|
251
|
-
.vdr-stick.not-resizable[data-v-ab09ceac] {
|
252
|
-
display: none;
|
253
|
-
}
|
254
|
-
.content-container[data-v-ab09ceac] {
|
255
|
-
display: block;
|
256
|
-
position: relative;
|
257
|
-
}
|
258
|
-
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -4,7 +4,8 @@ import { EMacro } from "./utilities/File";
|
|
4
4
|
|
5
5
|
import FileViewer from './views/FileViewer/index.vue'
|
6
6
|
import ImageViewer from './views/ImageViewer/index.vue'
|
7
|
-
import DragResizeView from './views/
|
7
|
+
import DragResizeView from './views/DragResizeView/index.vue'
|
8
|
+
import DragView from './views/Draw/index.vue'
|
8
9
|
import MessageBoxTest from "@/components/MessageBoxTest";
|
9
10
|
|
10
11
|
const components = [FileViewer, ImageViewer, DragResizeView];
|
package/src/utilities/File.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
import * as XLSX from "xlsx";
|
2
3
|
|
3
4
|
export namespace EMacro {
|
@@ -6,7 +7,76 @@ export namespace EMacro {
|
|
6
7
|
|
7
8
|
export class File {
|
8
9
|
|
9
|
-
|
10
|
+
public static getFileMD5(file: File): string {
|
11
|
+
|
12
|
+
throw "NG"
|
13
|
+
}
|
14
|
+
|
15
|
+
private static getBase64(blob) {
|
16
|
+
return new Promise((resolve, reject) => {
|
17
|
+
const reader = new FileReader();
|
18
|
+
reader.readAsDataURL(blob);
|
19
|
+
reader.onload = () => resolve(reader.result);
|
20
|
+
reader.onerror = error => reject(error);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
public static getFileChunks(file: any): any {
|
25
|
+
let { size } = file
|
26
|
+
const sliceSize = 1024 * 1024 * 2;
|
27
|
+
let totalChunks = Math.ceil(size / sliceSize)
|
28
|
+
let fileChunks = new Array<any>()
|
29
|
+
if (size > sliceSize) {
|
30
|
+
for (let i = 0; i < totalChunks; i++) {
|
31
|
+
let start = i * sliceSize
|
32
|
+
let end = (i + 1) * sliceSize
|
33
|
+
let chunk = file.slice(start, end)
|
34
|
+
fileChunks.push(chunk)
|
35
|
+
}
|
36
|
+
} else {
|
37
|
+
fileChunks.push(file)
|
38
|
+
}
|
39
|
+
return { "fileChunks": fileChunks, "sliceSize": sliceSize, "chunksLength": fileChunks.length }
|
40
|
+
}
|
41
|
+
|
42
|
+
// 文件上传
|
43
|
+
public static uploadFiles(files, savePath, postFunc, errFunc, uploadedFunc) {
|
44
|
+
|
45
|
+
if (files[0].fileName == "" || files[0].fileSize == "" || files[0].fileSize == 0) {
|
46
|
+
throw new Error("请选择要上传的文件")
|
47
|
+
}
|
48
|
+
|
49
|
+
let that = this
|
50
|
+
for (let i = 0; i < files.length; i++) {
|
51
|
+
const file = files[i];
|
52
|
+
let { fileChunks, sliceSize, chunksLength } = File.getFileChunks(file.file)
|
53
|
+
for (let index in fileChunks) {
|
54
|
+
let chunk = fileChunks[Number(index)]
|
55
|
+
|
56
|
+
setTimeout(async () => {
|
57
|
+
await File.getBase64(chunk).then((base64: any) => {
|
58
|
+
let data = {
|
59
|
+
'chunkIndex': Number(index), // 分片位置
|
60
|
+
'chunksLength': chunksLength, // 分片长度
|
61
|
+
'sliceSize': sliceSize, // 分片大小
|
62
|
+
'chunkSize': chunk.size, // 当前分片实际大小
|
63
|
+
'fileSize': file.file.size, // 文件总大小
|
64
|
+
'fileName': file.file.name, // 文件名
|
65
|
+
'data': base64.split(';base64,')[1], // 文件数据
|
66
|
+
'lastModifiedDate': file.file.lastModifiedDate, // 最后修改时间
|
67
|
+
'dataType': 'base64', // 数据的类型
|
68
|
+
'savePath': savePath
|
69
|
+
}
|
70
|
+
postFunc(data)
|
71
|
+
}).catch((err) => {
|
72
|
+
errFunc({ err: err, file: file.file, chunkIndex: index, fileName: file.file.name })
|
73
|
+
})
|
74
|
+
}, 10);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
public static selectFile(options: any = { multiple: true, accept: "*/*" }): Promise<FileList | null> {
|
10
80
|
return new Promise((res: (value: FileList) => void, rej) => {
|
11
81
|
const el = document.createElement("input");
|
12
82
|
el.type = "file";
|
@@ -29,7 +99,10 @@ export namespace EMacro {
|
|
29
99
|
|
30
100
|
public static readLocalExcel(onloadend: (file, workbook) => void, options: any = { multiple: true, accept: "*/*" }) {
|
31
101
|
|
32
|
-
this.selectFile(options).then((files: FileList) => {
|
102
|
+
this.selectFile(options).then((files: FileList | null) => {
|
103
|
+
if (files === null) {
|
104
|
+
return
|
105
|
+
}
|
33
106
|
for (let i = 0; i < files.length; i++) {
|
34
107
|
const file = files[i];
|
35
108
|
let reader = new FileReader();
|
@@ -47,8 +120,7 @@ export namespace EMacro {
|
|
47
120
|
}
|
48
121
|
|
49
122
|
}
|
50
|
-
|
51
123
|
|
52
124
|
|
53
125
|
|
54
|
-
|
126
|
+
|
@@ -1,10 +1,3 @@
|
|
1
|
-
.app-container {
|
2
|
-
height: 100%;
|
3
|
-
width: 100%;
|
4
|
-
margin: 0;
|
5
|
-
padding: 0;
|
6
|
-
}
|
7
|
-
|
8
1
|
.vdr {
|
9
2
|
position: absolute;
|
10
3
|
box-sizing: border-box;
|
@@ -26,7 +19,7 @@
|
|
26
19
|
position: absolute;
|
27
20
|
font-size: 1px;
|
28
21
|
background: #ffffff;
|
29
|
-
border:
|
22
|
+
border: 2px solid #6c6c6c;
|
30
23
|
box-shadow: 0 0 2px #bbb;
|
31
24
|
}
|
32
25
|
|