emacroh5lib 1.0.30 → 1.0.33
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
package/src/utilities/File.ts
CHANGED
@@ -6,7 +6,7 @@ import createTaskQueue from 'sync-task-queue'
|
|
6
6
|
|
7
7
|
export namespace EMacro {
|
8
8
|
|
9
|
-
export const version = "1.
|
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 async uploadFiles(files,
|
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("文件异常")
|
@@ -76,7 +74,7 @@ export namespace EMacro {
|
|
76
74
|
for (let index in fileChunks) {
|
77
75
|
let chunk = fileChunks[Number(index)]
|
78
76
|
const base64 = await File.getBase64(chunk) as string
|
79
|
-
let
|
77
|
+
let chunkFile = {
|
80
78
|
'chunkIndex': Number(index), // 分片位置
|
81
79
|
'chunksLength': chunksLength, // 分片长度
|
82
80
|
'sliceSize': sliceSize, // 分片大小
|
@@ -86,12 +84,14 @@ export namespace EMacro {
|
|
86
84
|
'data': base64.split(';base64,')[1], // 文件数据
|
87
85
|
'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
|
88
86
|
'md5': md5,
|
87
|
+
'index': i,
|
89
88
|
'dataType': 'base64' // 数据的类型
|
90
89
|
}
|
91
|
-
await
|
90
|
+
await chunkFileHandle(chunkFile)
|
92
91
|
}
|
93
|
-
|
92
|
+
fileComplete(file);
|
94
93
|
}
|
94
|
+
completeHandle(files)
|
95
95
|
}
|
96
96
|
|
97
97
|
public static selectFile(options: any = { multiple: true, accept: "*/*" }): Promise<FileList | null> {
|
@@ -137,6 +137,23 @@ export namespace EMacro {
|
|
137
137
|
|
138
138
|
}
|
139
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
|
+
|
140
157
|
}
|
141
158
|
|
142
159
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="duo-viewer" v-if="show" ref="duoViewer" @click="clickAgent">
|
3
3
|
<div class="duo-viewer-mask">
|
4
|
-
<img ref="duoViewerImage" :src="realSrc" alt="
|
4
|
+
<img ref="duoViewerImage" :src="realSrc" :alt="alt" class="duo-viewer-mask__image" />
|
5
5
|
</div>
|
6
6
|
<div class="duo-viewer-footer">
|
7
7
|
<div class="duo-viewer-footer__title">{{ realName }}</div>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
? 'duo-viewer-footer__navbar-thumbnail-item viewer-current'
|
30
30
|
: 'duo-viewer-footer__navbar-thumbnail-item'
|
31
31
|
">
|
32
|
-
<img data-viewer-action="select" :data-viewer-action-index="i" :src="item" alt="
|
32
|
+
<img data-viewer-action="select" :data-viewer-action-index="i" :src="item" :alt="alt"
|
33
33
|
class="duo-viewer-footer__navbar-thumbnail-image" />
|
34
34
|
</div>
|
35
35
|
</div>
|
@@ -43,7 +43,9 @@
|
|
43
43
|
</template>
|
44
44
|
|
45
45
|
<script>
|
46
|
-
|
46
|
+
|
47
|
+
// 需优化问题,图片很多时卡顿, 增加页面宽高自适应按钮
|
48
|
+
// 缩放时变形
|
47
49
|
|
48
50
|
export default {
|
49
51
|
name: "ImageViewer",
|
@@ -77,11 +79,21 @@
|
|
77
79
|
},
|
78
80
|
shrink: {
|
79
81
|
type: Number,
|
80
|
-
default: .
|
82
|
+
default: .6,
|
81
83
|
},
|
82
84
|
enlarge: {
|
83
85
|
type: Number,
|
84
86
|
default: .6,
|
87
|
+
},
|
88
|
+
alt: {
|
89
|
+
type: String,
|
90
|
+
default: "加载失败...",
|
91
|
+
},
|
92
|
+
loadComplete: {
|
93
|
+
type: Function,
|
94
|
+
default: (on, event) => {
|
95
|
+
console.log("loadComplete", on, event);
|
96
|
+
}
|
85
97
|
}
|
86
98
|
},
|
87
99
|
computed: {
|
@@ -133,7 +145,8 @@
|
|
133
145
|
const imageObject = new Image();
|
134
146
|
promises.push(
|
135
147
|
new Promise((resolve) => {
|
136
|
-
imageObject.onload = function () {
|
148
|
+
imageObject.onload = function (event) {
|
149
|
+
|
137
150
|
$this.listDataCache[i] = {
|
138
151
|
transform: {
|
139
152
|
scaleX: "1",
|
@@ -148,22 +161,38 @@
|
|
148
161
|
height: `${imageObject.height}px`,
|
149
162
|
};
|
150
163
|
|
151
|
-
resolve(
|
164
|
+
resolve(event);
|
165
|
+
$this.loadComplete("onload", event)
|
152
166
|
imageObject.onload = null
|
153
167
|
};
|
168
|
+
|
169
|
+
imageObject.onerror = function (event) {
|
170
|
+
resolve(event);
|
171
|
+
$this.loadComplete("onerror", event)
|
172
|
+
imageObject.onerror = null
|
173
|
+
};
|
174
|
+
|
154
175
|
imageObject.src = item;
|
155
176
|
})
|
156
177
|
);
|
157
178
|
});
|
158
179
|
|
159
|
-
Promise.all(promises).then((data) => {
|
180
|
+
// Promise.all(promises).then((data) => {
|
181
|
+
// this.image = this.$refs["duoViewerImage"];
|
182
|
+
// this.initDrag();
|
183
|
+
// const { width, height } = $this.listDataCache[index];
|
184
|
+
// $this.setStyleByName($this.image, "width", width);
|
185
|
+
// $this.setStyleByName($this.image, "height", height);
|
186
|
+
// })
|
187
|
+
|
188
|
+
Promise.race(promises).then((data) => {
|
160
189
|
this.image = this.$refs["duoViewerImage"];
|
161
190
|
this.initDrag();
|
162
191
|
const { width, height } = $this.listDataCache[index];
|
163
|
-
|
164
192
|
$this.setStyleByName($this.image, "width", width);
|
165
193
|
$this.setStyleByName($this.image, "height", height);
|
166
|
-
})
|
194
|
+
})
|
195
|
+
|
167
196
|
},
|
168
197
|
// Reset position
|
169
198
|
resetPosition() {
|
@@ -335,8 +364,8 @@
|
|
335
364
|
if (h <= 20 && type === "out") return;
|
336
365
|
|
337
366
|
if (type === "out") {
|
338
|
-
this.setStyleByName(image, "width", `${w * this.shrink}px`);
|
339
|
-
this.setStyleByName(image, "height", `${h * this.shrink}px`);
|
367
|
+
this.setStyleByName(image, "width", `${w * (1 - this.shrink)}px`);
|
368
|
+
this.setStyleByName(image, "height", `${h * (1 - this.shrink)}px`);
|
340
369
|
} else {
|
341
370
|
this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
|
342
371
|
this.setStyleByName(image, "height", `${h * (1 + this.enlarge)}px`);
|
@@ -528,5 +557,6 @@
|
|
528
557
|
};
|
529
558
|
</script>
|
530
559
|
|
531
|
-
<style>
|
560
|
+
<style lang="less" scoped>
|
561
|
+
@import "./style/css/index.css";
|
532
562
|
</style>
|
@@ -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"
|
@@ -65,6 +63,7 @@ export default class TestView extends Vue {
|
|
65
63
|
|
66
64
|
public currentIndex: Number = 0; // 打开图片查看器时,需要定位到的图片的索引
|
67
65
|
public srcList: Array<String> = [
|
66
|
+
"http://172.16.1.83:18019/EMacroApi/GetFile?type=0&path=C:\\MES\\EMacroAndroidServer_Windows_v1.1\\EMacroAssets\\file\\%E6%97%A0%E6%A0%87%E9%A2%98.png",
|
68
67
|
"https://scpic.chinaz.net/files/pic/pic9/202203/apic39703.jpg",
|
69
68
|
"https://scpic.chinaz.net/files/pic/pic9/202005/zzpic24899.jpg",
|
70
69
|
"https://scpic.chinaz.net/files/pic/pic9/202109/bpic24244.jpg",
|
@@ -209,8 +208,7 @@ export default class TestView extends Vue {
|
|
209
208
|
}
|
210
209
|
|
211
210
|
public selectFile(e) {
|
212
|
-
|
213
|
-
|
211
|
+
|
214
212
|
EMacro.File.selectFile().then((files) => {
|
215
213
|
EMacro.File.uploadFiles(files, file => {
|
216
214
|
|