emacroh5lib 1.0.32 → 1.0.35

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.32",
3
+ "version": "1.0.35",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -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="image" class="duo-viewer-mask__image" />
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="image"
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: .4,
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: function () {
95
+ console.log("loadComplete");
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,37 @@
151
161
  height: `${imageObject.height}px`,
152
162
  };
153
163
 
154
- resolve("");
164
+ resolve(event);
155
165
  imageObject.onload = null
156
166
  };
167
+
168
+ imageObject.onerror = function (event) {
169
+ resolve(event);
170
+ imageObject.onerror = null
171
+ };
172
+
157
173
  imageObject.src = item;
158
174
  })
159
175
  );
160
176
  });
161
177
 
162
- Promise.all(promises).then((data) => {
163
- this.image = this.$refs["duoViewerImage"];
164
- this.initDrag();
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) => {
187
+ $this.image = this.$refs["duoViewerImage"];
188
+ $this.initDrag();
189
+ $this.loadComplete()
165
190
  const { width, height } = $this.listDataCache[index];
166
-
167
191
  $this.setStyleByName($this.image, "width", width);
168
192
  $this.setStyleByName($this.image, "height", height);
169
- });
193
+ })
194
+
170
195
  },
171
196
  // Reset position
172
197
  resetPosition() {
@@ -338,8 +363,8 @@
338
363
  if (h <= 20 && type === "out") return;
339
364
 
340
365
  if (type === "out") {
341
- this.setStyleByName(image, "width", `${w * this.shrink}px`);
342
- this.setStyleByName(image, "height", `${h * this.shrink}px`);
366
+ this.setStyleByName(image, "width", `${w * (1 - this.shrink)}px`);
367
+ this.setStyleByName(image, "height", `${h * (1 - this.shrink)}px`);
343
368
  } else {
344
369
  this.setStyleByName(image, "width", `${w * (1 + this.enlarge)}px`);
345
370
  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