emacroh5lib 1.0.75 → 1.0.79

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.75",
3
+ "version": "1.0.79",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -6,11 +6,12 @@ import FileViewer from './views/FileViewer/index.vue'
6
6
  import ImageViewer from './views/ImageViewer/index.vue'
7
7
  import VideoViewer from './views/VideoViewer/index.vue'
8
8
  import ModelViewer from './views/ModelViewer/index.vue'
9
+ import HtmlViewer from './views/HtmlViewer/index.vue'
9
10
  import DragResizeView from './views/DragResizeView/index.vue'
10
11
  import DragView from './views/Draw/index.vue'
11
12
  import MessageBoxTest from "@/components/MessageBoxTest";
12
13
 
13
- const components = [FileViewer, ImageViewer, VideoViewer, DragResizeView, ModelViewer];
14
+ const components = [FileViewer, ImageViewer, VideoViewer, DragResizeView, ModelViewer, HtmlViewer];
14
15
 
15
16
  const install = (Vue: any) => {
16
17
  if ((install as any).installed) return;
@@ -33,4 +34,4 @@ if (typeof window !== 'undefined' && (window as any).Vue) {
33
34
 
34
35
 
35
36
  export default {}
36
- export { EMacro, FileViewer, ImageViewer, VideoViewer, ModelViewer, DragResizeView }
37
+ export { EMacro, FileViewer, ImageViewer, VideoViewer, ModelViewer, DragResizeView, HtmlViewer }
@@ -74,9 +74,9 @@ export namespace EMacro {
74
74
  let directoryName = "";
75
75
  if (files[i].webkitRelativePath != null && files[i].webkitRelativePath.trim() != "") {
76
76
  let n = files[i].webkitRelativePath.lastIndexOf("\\")
77
- if (n == -1)
77
+ if (n == -1)
78
78
  n = files[i].webkitRelativePath.lastIndexOf("/")
79
- if (n != -1)
79
+ if (n != -1)
80
80
  directoryName = files[i].webkitRelativePath.substring(0, n)
81
81
  }
82
82
 
@@ -90,12 +90,13 @@ export namespace EMacro {
90
90
  'chunkSize': chunk.size, // 当前分片实际大小
91
91
  'fileSize': file.size, // 文件总大小
92
92
  'fileName': file.name, // 文件名
93
- 'data': base64.split(';base64,')[1], // 文件数据
94
93
  'lastModifiedDate': file.lastModifiedDate, // 最后修改时间
95
94
  'md5': md5,
96
95
  'index': i,
97
96
  'dataType': 'base64', // 数据的类型
98
- 'directoryName': directoryName // 数据的类型
97
+ 'directoryName': directoryName, // 数据的类型
98
+ 'total': files.length, // 总共文件数
99
+ 'data': base64.split(';base64,')[1], // 文件数据
99
100
  }
100
101
  await chunkFileHandle(chunkFile)
101
102
  }
@@ -104,7 +105,7 @@ export namespace EMacro {
104
105
  completeHandle(files)
105
106
  }
106
107
 
107
- public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = false): Promise<FileList | null> {
108
+ public static selectFile(options: any = { multiple: true, accept: "*/*" }, isDirectory = true): Promise<FileList | null> {
108
109
  return new Promise((res: (value: FileList) => void, rej) => {
109
110
  const el = document.createElement("input");
110
111
  el.type = "file";
@@ -255,6 +256,15 @@ export namespace EMacro {
255
256
  return fileName.substring(0, n) + extension;
256
257
  }
257
258
 
259
+ export const isURL = (strUrl) => {
260
+ const regular = /^\b(((https?|ftp):\/\/)?[-a-z0-9]+(\.[-a-z0-9]+)*\.(?:com|edu|gov|int|mil|net|org|biz|info|name|museum|asia|coop|aero|[a-z][a-z]|((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d))\b(\/[-a-z0-9_:\@&?=+,.!\/~%\$]*)?)$/i;
261
+ if (regular.test(strUrl.trim())) {
262
+ return true;
263
+ } else {
264
+ return false;
265
+ }
266
+ }
267
+
258
268
  }
259
269
 
260
270
 
@@ -0,0 +1,357 @@
1
+ <template>
2
+ <div class="duo-viewer" v-if="show" ref="duoViewer" @click="clickAgent">
3
+ <div class="duo-viewer-mask" >
4
+ <div id="viewer" class="duo-viewer-mask__image" :style="viewerStyle()">
5
+ <iframe :onload='onload()' :src="currentWebsite" ref="microApp" id='micro-app' height="100%" width="100%"
6
+ frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes" allowtransparency="yes" seamless
7
+ allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
8
+ </div>
9
+ </div>
10
+ <div class="duo-viewer-footer" v-if="showThumbnail">
11
+ <div class="duo-viewer-footer__title">{{ realName }}</div>
12
+ <div class="duo-viewer-footer__toolbar">
13
+ <ul>
14
+ <li class="duo-viewer-footer__zoom-in" data-viewer-action="zoom-in"></li>
15
+ <li class="duo-viewer-footer__zoom-out" data-viewer-action="zoom-out"></li>
16
+ <li class="duo-viewer-footer__one-to-one" data-viewer-action="one-to-one"></li>
17
+ <li class="duo-viewer-footer__prev" data-viewer-action="prev"></li>
18
+
19
+ <li class="duo-viewer-footer__play" data-viewer-action="play"></li>
20
+
21
+ <li class="duo-viewer-footer__next" data-viewer-action="next"></li>
22
+ <li class="duo-viewer-footer__reset" data-viewer-action="reset"></li>
23
+ <li class="duo-viewer-footer__rotate-left" data-viewer-action="rotate-left"></li>
24
+ <li class="duo-viewer-footer__rotate-right" data-viewer-action="rotate-right"></li>
25
+ </ul>
26
+ </div>
27
+ <div class="duo-viewer-footer__navbar">
28
+ <div class="duo-viewer-footer__navbar-thumbnail-wrap">
29
+ <div ref="duoViewerImageThumbnailList" class="duo-viewer-footer__navbar-thumbnail-list"
30
+ :style="{ width: `${listLength * 34}px` }">
31
+ <div :key="item + i" v-for="(item, i) in list" :class="
32
+ i === index
33
+ ? 'duo-viewer-footer__navbar-thumbnail-item viewer-current'
34
+ : 'duo-viewer-footer__navbar-thumbnail-item'
35
+ ">
36
+ <img data-viewer-action="select" :data-viewer-action-index="i" :src="getModelImg(item, i)" :alt="alt"
37
+ class="duo-viewer-footer__navbar-thumbnail-image" />
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ <div class="duo-viewer-close" @click="handleClose">
44
+ <div class="duo-viewer-close__off"></div>
45
+ </div>
46
+ </div>
47
+ </template>
48
+
49
+ <script>
50
+
51
+ import * as THREE from "three";
52
+ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
53
+ import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader.js";
54
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
55
+ import { STLLoader } from "three/examples/jsm/loaders/STLLoader.js";
56
+ import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader.js";
57
+ import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
58
+ import { Line2 } from 'three/examples/jsm/lines/Line2'
59
+ import { CSS2DObject, CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer";
60
+ import { AsciiEffect } from "three/examples/jsm/effects/AsciiEffect.js";
61
+ // import TWEEN from "@tweenjs/tween.js";
62
+ // import Stats from "stats.js";
63
+ // import * as dat from "dat.gui";
64
+
65
+ export default {
66
+ name: "ModelViewer",
67
+ data() {
68
+ return {
69
+ viewerSrc: "",
70
+ image: null,
71
+ index: 0,
72
+ imgUrl: "",
73
+ isCreatePoster: false,
74
+ gl: {
75
+ scene: null,
76
+ renderer: null,
77
+ camera: null,
78
+ controls: null,
79
+ geometry: null,
80
+ isRotate: false,
81
+ isMove: false,
82
+ startEvent: null,
83
+ WebGLoutput: null,
84
+ animationFrame: null
85
+ }
86
+ };
87
+ },
88
+ props: {
89
+ list: {
90
+ type: [Array, String],
91
+ default: () => [],
92
+ },
93
+ // Control is show of viewer
94
+ show: {
95
+ type: Boolean,
96
+ default: false,
97
+ },
98
+ // Default index
99
+ currentIndex: {
100
+ type: Number,
101
+ default: 0,
102
+ },
103
+ width: {
104
+ type: String,
105
+ default: "80%",
106
+ },
107
+ height: {
108
+ type: String,
109
+ default: "80%",
110
+ },
111
+ showThumbnail: {
112
+ type: Boolean,
113
+ default: false,
114
+ }
115
+ },
116
+ computed: {
117
+ listLength() {
118
+ return this.list.length;
119
+ },
120
+ realName() {
121
+ return this.list[this.index].name;
122
+ },
123
+ currentWebsite() {
124
+ if (typeof this.list === "string")
125
+ return this.list
126
+ return this.list[this.index].src;
127
+ }
128
+ },
129
+ watch: {
130
+ show(val) {
131
+ if (val) {
132
+ this.$emit("open");
133
+ this.index = this.currentIndex;
134
+ this.init();
135
+ } else {
136
+ this.$emit("close");
137
+ }
138
+ },
139
+ },
140
+ mounted() {
141
+
142
+ },
143
+ methods: {
144
+ viewerStyle() {
145
+ return `width:${this.width};height:${this.height};`;
146
+ },
147
+ getModelImg(item) {
148
+
149
+ },
150
+ onload() {
151
+ console.log("加载完毕...");
152
+ },
153
+ // Global init
154
+ init() {
155
+ console.log("你好");
156
+ // this.initMouseWheel();
157
+ this.keydown();
158
+ },
159
+
160
+ // Next or prev action
161
+ switchAction(a) {
162
+ let lastIndex = this.index;
163
+ switch (a) {
164
+ case "prev":
165
+ // prev action
166
+ this.index += this.index <= 0 ? 0 : -1;
167
+ break;
168
+ case "next": {
169
+ // next action
170
+ let srcListLength = this.listLength - 1;
171
+
172
+ this.index +=
173
+ this.index >= srcListLength ? srcListLength - this.index : 1;
174
+ }
175
+ break;
176
+ default:
177
+ this.index = +a;
178
+ break;
179
+ }
180
+ this.judgeThumbnailListMove(lastIndex, this.index);
181
+
182
+ },
183
+ // To judge thumbnail list move
184
+ judgeThumbnailListMove(lastIndex, index) {
185
+ if (lastIndex == index) return;
186
+
187
+ let translateX = 0,
188
+ lastTransform = 0,
189
+ step = index - lastIndex,
190
+ move = step * 34,
191
+ length = this.listLength,
192
+ target = this.$refs["duoViewerImageThumbnailList"];
193
+
194
+ if (!target) return;
195
+
196
+ lastTransform = this.getCurrentTransform(target);
197
+
198
+ if (lastTransform) {
199
+ translateX = Math.abs(+lastTransform.translateX);
200
+ }
201
+
202
+ this.setTransform(target, {
203
+ scaleX: "1",
204
+ skewY: "0",
205
+ translateX: `-${translateX + move}px`,
206
+ translateY: "0%",
207
+ rotate: "0deg",
208
+ });
209
+ },
210
+
211
+
212
+ // FullScreen action
213
+ requestFullScreen() {
214
+
215
+
216
+
217
+ const isFullScreen = document.fullscreenElement
218
+
219
+ if (isFullScreen) {
220
+
221
+ if (document.exitFullscreen) {
222
+ document.exitFullscreen()
223
+ } else if (document.msExitFullscreen) {
224
+ document.msExitFullscreen()
225
+ } else if (document.mozCancelFullScreen) {
226
+ document.mozCancelFullScreen()
227
+ } else if (document.webkitCancelFullScreen) {
228
+ document.webkitCancelFullScreen()
229
+ }
230
+
231
+ } else {
232
+ let element = this.$refs["duoViewer"],
233
+ requestMethod =
234
+ element.requestFullScreen ||
235
+ element.webkitRequestFullScreen ||
236
+ element.mozRequestFullScreen ||
237
+ element.msRequestFullScreen;
238
+
239
+ if (requestMethod) {
240
+ requestMethod.call(element);
241
+ }
242
+ }
243
+
244
+ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty()
245
+
246
+ },
247
+
248
+ // Keydown action
249
+ keydown() {
250
+ window.addEventListener("keydown", (e) => {
251
+ e = event || window.event
252
+
253
+ if (e && e.keyCode == 40) {
254
+ // down
255
+ this.zoom("out");
256
+ }
257
+ if (e && e.keyCode == 37) {
258
+ // left
259
+ this.switchAction("prev");
260
+ }
261
+ if (e && e.keyCode == 39) {
262
+ // right
263
+ this.switchAction("next");
264
+ }
265
+ if (e && e.keyCode == 38) {
266
+ // up
267
+ this.zoom("in");
268
+ }
269
+ if (e && e.keyCode == 27) {
270
+ // esc
271
+ this.handleClose()
272
+ }
273
+ });
274
+ },
275
+
276
+ // Init mouse wheel event
277
+ initMouseWheel() {
278
+ const scrollFn = (e) => {
279
+ e = e || window.event;
280
+ if (e.wheelDelta) {
281
+ // for IE/Google
282
+ if (e.wheelDelta > 0) {
283
+ this.zoom("out");
284
+ }
285
+ if (e.wheelDelta < 0) {
286
+ this.zoom("in");
287
+ }
288
+ } else if (e.detail) {
289
+ // for Firefox
290
+ if (e.detail > 0) {
291
+ this.zoom("out");
292
+ }
293
+ if (e.detail < 0) {
294
+ this.zoom("in");
295
+ }
296
+ }
297
+ };
298
+
299
+ document.addEventListener &&
300
+ document.addEventListener("DOMMouseScroll", scrollFn, false);
301
+ window.onmousewheel = document.onmousewheel = scrollFn;
302
+ },
303
+
304
+ // Agent
305
+ clickAgent(e) {
306
+ switch (e.target.getAttribute("data-viewer-action")) {
307
+ case "zoom-in":
308
+ this.zoom("in");
309
+ break;
310
+ case "zoom-out":
311
+ this.zoom("out");
312
+ break;
313
+ case "one-to-one":
314
+ this.resetZoom();
315
+ break;
316
+ case "prev":
317
+ this.switchAction("prev");
318
+ break;
319
+ case "play":
320
+ this.requestFullScreen();
321
+ break;
322
+ case "next":
323
+ this.switchAction("next");
324
+ break;
325
+ case "reset":
326
+ this.resetAll();
327
+ break;
328
+ case "select":
329
+ this.switchAction(e.target.getAttribute("data-viewer-action-index"));
330
+ break;
331
+ case "rotate-left":
332
+ this.rotate("left");
333
+ break;
334
+ case "rotate-right":
335
+ this.rotate("right");
336
+ break;
337
+ }
338
+ },
339
+ // On close
340
+ handleClose() {
341
+
342
+ cancelAnimationFrame(this.gl.animationFrame)
343
+
344
+ const keys = Object.keys(this.gl)
345
+ for (let i = 0; i < keys.length; i++) {
346
+ this.gl[keys[i]] = null
347
+ }
348
+ this.$emit("update:show", false);
349
+ },
350
+ },
351
+ };
352
+ </script>
353
+
354
+ <style lang="less" scoped>
355
+ @import "./style/css/index.css";
356
+ /* @import "./style/css/index.less"; */
357
+ </style>
@@ -0,0 +1,190 @@
1
+ .duo-viewer {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: 10000;
6
+ width: 100%;
7
+ height: 100vh;
8
+ }
9
+ .duo-viewer-mask {
10
+ position: absolute;
11
+ top: 0;
12
+ left: 0;
13
+ width: 100%;
14
+ height: 100%;
15
+ background: rgba(0, 0, 0, 0.6);
16
+ z-index: 9;
17
+ display: flex;
18
+ justify-content: center;
19
+ align-items: center;
20
+ }
21
+ .duo-viewer-mask__image {
22
+ cursor: grab;
23
+ /* height: 80%;
24
+ width: 80%; */
25
+ position: absolute;
26
+ /* top: 50%;
27
+ left: 50%;
28
+ transform: translate(-50%, -50%); */
29
+ z-index: 8;
30
+ /* transition-property: transform, height, width; */
31
+ transition-duration: 0.3s, 0.3s, 0.3s;
32
+ }
33
+ .duo-viewer-footer {
34
+ position: absolute;
35
+ text-align: center;
36
+ bottom: 0;
37
+ left: 0;
38
+ width: 100%;
39
+ z-index: 10;
40
+ }
41
+ .duo-viewer-footer__title {
42
+ color: #cfcfcf;
43
+ position: absolute;
44
+ bottom: 95px;
45
+ left: 50%;
46
+ transform: translate(-50%, 0%);
47
+ z-index: 10;
48
+ width: 100%;
49
+ }
50
+ .duo-viewer-footer__toolbar {
51
+ position: absolute;
52
+ bottom: 60px;
53
+ left: 50%;
54
+ transform: translate(-50%, 0%);
55
+ z-index: 10;
56
+ }
57
+ .duo-viewer-footer__toolbar li {
58
+ margin: 2px;
59
+ background-color: rgba(0, 0, 0, 0.5);
60
+ border-radius: 50%;
61
+ cursor: pointer;
62
+ float: left;
63
+ height: 28px;
64
+ overflow: hidden;
65
+ -webkit-transition: background-color 0.15s;
66
+ transition: background-color 0.15s;
67
+ width: 28px;
68
+ position: relative;
69
+ }
70
+ .duo-viewer-footer__toolbar li::after {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ height: 100%;
76
+ content: "";
77
+ display: inline-block;
78
+ background: url("../images/icons.png") no-repeat;
79
+ }
80
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__zoom-in::after {
81
+ background-position: 4px 3px;
82
+ }
83
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__zoom-out::after {
84
+ background-position: -16px 3px;
85
+ }
86
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__one-to-one::after {
87
+ background-position: -35px 3px;
88
+ }
89
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__reset::after {
90
+ background-position: -56px 3px;
91
+ }
92
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__prev::after {
93
+ background-position: -77px 3px;
94
+ }
95
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__play {
96
+ width: 34px;
97
+ height: 34px;
98
+ margin-top: -2px;
99
+ }
100
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__play::after {
101
+ background-position: -93px 6px;
102
+ }
103
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__next::after {
104
+ background-position: -116px 3px;
105
+ }
106
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__rotate-left::after {
107
+ background-position: -136px 3px;
108
+ }
109
+ .duo-viewer-footer__toolbar li.duo-viewer-footer__rotate-right::after {
110
+ background-position: -156px 3px;
111
+ }
112
+ .duo-viewer-footer__navbar {
113
+ width: 100%;
114
+ height: 50px;
115
+ background: rgba(0, 0, 0, 0.9);
116
+ overflow: hidden;
117
+ }
118
+ .duo-viewer-footer__navbar-thumbnail-image {
119
+ height: 100%;
120
+ width: 80px;
121
+ -o-object-fit: fill;
122
+ object-fit: fill;
123
+ transform: translateX(-30px);
124
+ }
125
+ .duo-viewer-footer__navbar-thumbnail-item {
126
+ margin: 0 2px;
127
+ color: transparent;
128
+ cursor: pointer;
129
+ float: left;
130
+ font-size: 0;
131
+ width: 30px;
132
+ opacity: 0.2;
133
+ overflow: hidden;
134
+ -webkit-transition: opacity 0.15s;
135
+ transition: opacity 0.15s;
136
+ }
137
+ .duo-viewer-footer__navbar-thumbnail-item.viewer-current {
138
+ opacity: 0.9;
139
+ }
140
+ .duo-viewer-footer__navbar-thumbnail-wrap {
141
+ position: relative;
142
+ overflow: hidden;
143
+ width: 660px;
144
+ height: inherit;
145
+ margin: 0 auto;
146
+ }
147
+ .duo-viewer-footer__navbar-thumbnail-list {
148
+ padding: 10px 0;
149
+ width: auto;
150
+ box-sizing: border-box;
151
+ position: absolute;
152
+ top: 0;
153
+ left: 50%;
154
+ transition: all 0.3s;
155
+ }
156
+ .duo-viewer-close {
157
+ background-color: rgba(0, 0, 0, 0.9);
158
+ border-radius: 0% 0% 0% 100%;
159
+ cursor: pointer;
160
+ height: 50px;
161
+ overflow: hidden;
162
+ position: absolute;
163
+ right: 0;
164
+ top: 0;
165
+ transition: background-color 0.15s;
166
+ width: 50px;
167
+ z-index: 10;
168
+ line-height: 50px;
169
+ text-align: center;
170
+ }
171
+ .duo-viewer-close__off {
172
+ margin: 18px 12px;
173
+ position: relative;
174
+ width: 2em;
175
+ height: 0.3em;
176
+ background-color: #fff;
177
+ transform: rotate(45deg);
178
+ border-radius: 0.15em;
179
+ }
180
+ .duo-viewer-close__off:after {
181
+ content: "";
182
+ position: absolute;
183
+ width: 2em;
184
+ height: 0.3em;
185
+ top: 0;
186
+ left: 0;
187
+ background-color: #fff;
188
+ transform: rotate(90deg);
189
+ border-radius: 0.15em;
190
+ }