emacroh5lib 1.0.31 → 1.0.34
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,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: function () {
|
95
|
+
console.log("loadComplete");
|
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,41 @@
|
|
148
161
|
height: `${imageObject.height}px`,
|
149
162
|
};
|
150
163
|
|
151
|
-
resolve(
|
164
|
+
resolve(event);
|
152
165
|
imageObject.onload = null
|
153
166
|
};
|
167
|
+
|
168
|
+
imageObject.onerror = function (event) {
|
169
|
+
resolve(event);
|
170
|
+
imageObject.onerror = null
|
171
|
+
};
|
172
|
+
|
154
173
|
imageObject.src = item;
|
155
174
|
})
|
156
175
|
);
|
157
176
|
});
|
158
177
|
|
159
|
-
Promise.all(promises).then((data) => {
|
178
|
+
// Promise.all(promises).then((data) => {
|
179
|
+
// this.image = this.$refs["duoViewerImage"];
|
180
|
+
// this.initDrag();
|
181
|
+
// const { width, height } = $this.listDataCache[index];
|
182
|
+
// $this.setStyleByName($this.image, "width", width);
|
183
|
+
// $this.setStyleByName($this.image, "height", height);
|
184
|
+
// })
|
185
|
+
|
186
|
+
Promise.race(promises).then((data) => {
|
160
187
|
this.image = this.$refs["duoViewerImage"];
|
161
188
|
this.initDrag();
|
162
|
-
|
189
|
+
this.loadComplete()
|
190
|
+
try {
|
191
|
+
const { width, height } = $this.listDataCache[index];
|
192
|
+
$this.setStyleByName($this.image, "width", width);
|
193
|
+
$this.setStyleByName($this.image, "height", height);
|
194
|
+
} catch (error) {
|
195
|
+
console.log("promises", error);
|
196
|
+
}
|
197
|
+
})
|
163
198
|
|
164
|
-
$this.setStyleByName($this.image, "width", width);
|
165
|
-
$this.setStyleByName($this.image, "height", height);
|
166
|
-
});
|
167
199
|
},
|
168
200
|
// Reset position
|
169
201
|
resetPosition() {
|
@@ -335,8 +367,8 @@
|
|
335
367
|
if (h <= 20 && type === "out") return;
|
336
368
|
|
337
369
|
if (type === "out") {
|
338
|
-
this.setStyleByName(image, "width", `${w * this.shrink}px`);
|
339
|
-
this.setStyleByName(image, "height", `${h * this.shrink}px`);
|
370
|
+
this.setStyleByName(image, "width", `${w * (1 - this.shrink)}px`);
|
371
|
+
this.setStyleByName(image, "height", `${h * (1 - this.shrink)}px`);
|
340
372
|
} else {
|
341
373
|
this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
|
342
374
|
this.setStyleByName(image, "height", `${h * (1 + this.enlarge)}px`);
|
@@ -528,5 +560,6 @@
|
|
528
560
|
};
|
529
561
|
</script>
|
530
562
|
|
531
|
-
<style>
|
563
|
+
<style lang="less" scoped>
|
564
|
+
@import "./style/css/index.css";
|
532
565
|
</style>
|
@@ -63,6 +63,7 @@ export default class TestView extends Vue {
|
|
63
63
|
|
64
64
|
public currentIndex: Number = 0; // 打开图片查看器时,需要定位到的图片的索引
|
65
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",
|
66
67
|
"https://scpic.chinaz.net/files/pic/pic9/202203/apic39703.jpg",
|
67
68
|
"https://scpic.chinaz.net/files/pic/pic9/202005/zzpic24899.jpg",
|
68
69
|
"https://scpic.chinaz.net/files/pic/pic9/202109/bpic24244.jpg",
|
@@ -207,8 +208,7 @@ export default class TestView extends Vue {
|
|
207
208
|
}
|
208
209
|
|
209
210
|
public selectFile(e) {
|
210
|
-
|
211
|
-
|
211
|
+
|
212
212
|
EMacro.File.selectFile().then((files) => {
|
213
213
|
EMacro.File.uploadFiles(files, file => {
|
214
214
|
|