emacroh5lib 1.0.32 → 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
@@ -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>
|
@@ -45,8 +45,7 @@
|
|
45
45
|
<script>
|
46
46
|
|
47
47
|
// 需优化问题,图片很多时卡顿, 增加页面宽高自适应按钮
|
48
|
-
|
49
|
-
|
48
|
+
// 缩放时变形
|
50
49
|
|
51
50
|
export default {
|
52
51
|
name: "ImageViewer",
|
@@ -80,11 +79,21 @@
|
|
80
79
|
},
|
81
80
|
shrink: {
|
82
81
|
type: Number,
|
83
|
-
default: .
|
82
|
+
default: .6,
|
84
83
|
},
|
85
84
|
enlarge: {
|
86
85
|
type: Number,
|
87
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
|
+
}
|
88
97
|
}
|
89
98
|
},
|
90
99
|
computed: {
|
@@ -136,7 +145,8 @@
|
|
136
145
|
const imageObject = new Image();
|
137
146
|
promises.push(
|
138
147
|
new Promise((resolve) => {
|
139
|
-
imageObject.onload = function () {
|
148
|
+
imageObject.onload = function (event) {
|
149
|
+
|
140
150
|
$this.listDataCache[i] = {
|
141
151
|
transform: {
|
142
152
|
scaleX: "1",
|
@@ -151,22 +161,38 @@
|
|
151
161
|
height: `${imageObject.height}px`,
|
152
162
|
};
|
153
163
|
|
154
|
-
resolve(
|
164
|
+
resolve(event);
|
165
|
+
$this.loadComplete("onload", event)
|
155
166
|
imageObject.onload = null
|
156
167
|
};
|
168
|
+
|
169
|
+
imageObject.onerror = function (event) {
|
170
|
+
resolve(event);
|
171
|
+
$this.loadComplete("onerror", event)
|
172
|
+
imageObject.onerror = null
|
173
|
+
};
|
174
|
+
|
157
175
|
imageObject.src = item;
|
158
176
|
})
|
159
177
|
);
|
160
178
|
});
|
161
179
|
|
162
|
-
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) => {
|
163
189
|
this.image = this.$refs["duoViewerImage"];
|
164
190
|
this.initDrag();
|
165
191
|
const { width, height } = $this.listDataCache[index];
|
166
|
-
|
167
192
|
$this.setStyleByName($this.image, "width", width);
|
168
193
|
$this.setStyleByName($this.image, "height", height);
|
169
|
-
})
|
194
|
+
})
|
195
|
+
|
170
196
|
},
|
171
197
|
// Reset position
|
172
198
|
resetPosition() {
|
@@ -338,8 +364,8 @@
|
|
338
364
|
if (h <= 20 && type === "out") return;
|
339
365
|
|
340
366
|
if (type === "out") {
|
341
|
-
this.setStyleByName(image, "width", `${w * this.shrink}px`);
|
342
|
-
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`);
|
343
369
|
} else {
|
344
370
|
this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
|
345
371
|
this.setStyleByName(image, "height", `${h * (1 + this.enlarge)}px`);
|
@@ -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
|
|