@seresweb/website-component 2.2.0 → 2.2.2

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/dist/es/video.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as L, ref as d, watch as A, nextTick as E, onMounted as O, onBeforeUnmount as M, createElementBlock as h, openBlock as r, normalizeClass as f, createElementVNode as y, createCommentVNode as _, renderSlot as V, onUnmounted as U, Fragment as S, createBlock as $, mergeProps as T, normalizeStyle as H, unref as N, toDisplayString as X, Teleport as F, createVNode as Y } from "vue";
2
- import { P as u } from "../_vars-BV4QQF-p.js";
1
+ import { defineComponent as S, ref as d, watch as F, nextTick as N, onMounted as L, onBeforeUnmount as X, createElementBlock as C, openBlock as c, normalizeClass as y, createElementVNode as i, createCommentVNode as R, renderSlot as b, onUnmounted as E, createBlock as x, mergeProps as V, Fragment as O, normalizeStyle as U, unref as W, toDisplayString as H, Teleport as Y, createVNode as z, withCtx as $ } from "vue";
2
+ import { P as f } from "../_vars-BV4QQF-p.js";
3
3
  import { ScLayzImage as j } from "./layz-image.mjs";
4
- const D = ["controls", "poster", "src"], z = /* @__PURE__ */ L({
4
+ const D = ["controls", "poster", "src"], I = /* @__PURE__ */ S({
5
5
  __name: "video-wrapper",
6
6
  props: {
7
7
  class: {},
@@ -16,83 +16,83 @@ const D = ["controls", "poster", "src"], z = /* @__PURE__ */ L({
16
16
  urlSmall: {}
17
17
  },
18
18
  emits: ["paused"],
19
- setup(m, { expose: e, emit: C }) {
20
- const l = m, k = C, g = /xiaomi|miui/i, x = `${u}-player-wrapper`, w = `${u}-player-is-fullscreen`, B = `${u}-player-close-btn`, b = `${u}-player-icon`, t = d(), s = d(!0), p = d(g.test(navigator.userAgent) ? void 0 : l.url);
21
- let n = null;
22
- const o = (a) => {
23
- var c, i;
24
- a.target !== t.value && ((c = t.value) == null || c.pause(), s.value = !!((i = t.value) != null && i.paused), k("paused"));
25
- }, v = (a) => {
26
- const c = a[0], i = t.value;
27
- !i || !l.playable || (c.isIntersecting && l.autoPlay && i.paused ? (i.play().catch(console.warn), s.value = !1) : !c.isIntersecting && !i.paused && (i.pause(), s.value = !0));
28
- }, P = () => {
29
- l.autoPlay && l.playable && t.value && (n = new IntersectionObserver(v, {
19
+ setup(v, { expose: w, emit: e }) {
20
+ const t = v, o = e, P = /xiaomi|miui/i, T = `${f}-player-wrapper`, g = `${f}-player-is-fullscreen`, m = `${f}-player-close-btn`, _ = `${f}-player-icon`, a = d(), n = d(!0), k = d(P.test(navigator.userAgent) ? void 0 : t.url);
21
+ let r = null;
22
+ const s = (p) => {
23
+ var h, B;
24
+ p.target !== a.value && ((h = a.value) == null || h.pause(), n.value = !!((B = a.value) != null && B.paused), o("paused"));
25
+ }, l = (p) => {
26
+ const h = p[0], B = a.value;
27
+ !B || !t.playable || (h.isIntersecting && t.autoPlay && B.paused ? (B.play().catch(console.warn), n.value = !1) : !h.isIntersecting && !B.paused && (B.pause(), n.value = !0));
28
+ }, u = () => {
29
+ t.autoPlay && t.playable && a.value && (r = new IntersectionObserver(l, {
30
30
  threshold: 0.25
31
31
  // 可根据需求调整可见区域百分比
32
- }), n.observe(t.value));
33
- }, I = () => {
34
- n == null || n.disconnect(), n = null;
32
+ }), r.observe(a.value));
33
+ }, A = () => {
34
+ r == null || r.disconnect(), r = null;
35
35
  };
36
- return A(
37
- () => l.playable,
36
+ return F(
37
+ () => t.playable,
38
38
  () => {
39
- I(), E(() => P());
39
+ A(), N(() => u());
40
40
  }
41
- ), e({
41
+ ), w({
42
42
  play() {
43
- t.value.play(), s.value = t.value.paused;
43
+ a.value.play(), n.value = a.value.paused;
44
44
  },
45
45
  pause() {
46
- t.value.pause(), s.value = t.value.paused;
46
+ a.value.pause(), n.value = a.value.paused;
47
47
  }
48
- }), O(() => {
49
- g.test(navigator.userAgent) && fetch(l.url).then((a) => {
50
- if (!a.ok)
51
- throw new Error(`HTTP error! status: ${a.status}`);
52
- return a.blob();
53
- }).then((a) => {
54
- p.value = URL.createObjectURL(a);
55
- }).catch((a) => {
56
- console.error("获取视频失败:", a);
57
- }), P();
58
- }), M(() => {
59
- I();
60
- }), (a, c) => (r(), h(
48
+ }), L(() => {
49
+ P.test(navigator.userAgent) && fetch(t.url).then((p) => {
50
+ if (!p.ok)
51
+ throw new Error(`HTTP error! status: ${p.status}`);
52
+ return p.blob();
53
+ }).then((p) => {
54
+ k.value = URL.createObjectURL(p);
55
+ }).catch((p) => {
56
+ console.error("获取视频失败:", p);
57
+ }), u();
58
+ }), X(() => {
59
+ A();
60
+ }), (p, h) => (c(), C(
61
61
  "div",
62
62
  {
63
- class: f([x, l.class, !s.value && !l.autoPlay && w])
63
+ class: y([T, t.class, !n.value && !t.autoPlay && g])
64
64
  },
65
65
  [
66
- y("video", {
66
+ i("video", {
67
67
  ref_key: "videoRef",
68
- ref: t,
68
+ ref: a,
69
69
  muted: "",
70
70
  loop: "",
71
71
  playsinline: "",
72
72
  "webkit-playsinline": "",
73
73
  "x5-video-player-type": "h5",
74
- controls: !s.value && !l.autoPlay,
75
- poster: l.poster,
76
- src: p.value
74
+ controls: !n.value && !t.autoPlay,
75
+ poster: t.poster,
76
+ src: k.value
77
77
  }, null, 8, D),
78
- !s.value && !l.autoPlay ? (r(), h(
78
+ !n.value && !t.autoPlay ? (c(), C(
79
79
  "button",
80
80
  {
81
81
  key: 0,
82
- class: f([B, l.playerButtonClass]),
83
- onClick: o
82
+ class: y([m, t.playerButtonClass]),
83
+ onClick: s
84
84
  },
85
85
  [
86
- V(a.$slots, "close", {}, () => [
87
- (r(), h("svg", {
88
- class: f(b),
86
+ b(p.$slots, "close", {}, () => [
87
+ (c(), C("svg", {
88
+ class: y(_),
89
89
  viewBox: "0 0 1121 1024",
90
90
  version: "1.1",
91
91
  xmlns: "http://www.w3.org/2000/svg",
92
92
  width: "200",
93
93
  height: "200"
94
- }, [...c[0] || (c[0] = [
95
- y(
94
+ }, [...h[0] || (h[0] = [
95
+ i(
96
96
  "path",
97
97
  {
98
98
  d: "M1040.725333 49.005714l-965.485714 965.436953-48.420571-48.469334L992.256 0.487619l48.469333 48.518095z",
@@ -102,7 +102,7 @@ const D = ["controls", "poster", "src"], z = /* @__PURE__ */ L({
102
102
  -1
103
103
  /* CACHED */
104
104
  ),
105
- y(
105
+ i(
106
106
  "path",
107
107
  {
108
108
  d: "M1040.725333 1014.442667l-965.485714-965.485715 48.518095-48.420571L1089.194667 965.973333l-48.469334 48.469334z",
@@ -117,14 +117,162 @@ const D = ["controls", "poster", "src"], z = /* @__PURE__ */ L({
117
117
  ],
118
118
  2
119
119
  /* CLASS */
120
- )) : _("v-if", !0)
120
+ )) : R("v-if", !0)
121
121
  ],
122
122
  2
123
123
  /* CLASS */
124
124
  ));
125
125
  }
126
- }), R = /* @__PURE__ */ L({
127
- __name: "video",
126
+ }), G = /* @__PURE__ */ S({
127
+ __name: "video-normal",
128
+ props: {
129
+ class: {},
130
+ style: {},
131
+ playerButtonClass: {},
132
+ playerButtonText: { default: "PLAY" },
133
+ poster: { default: "" },
134
+ url: {},
135
+ autoPlay: { type: Boolean, default: !0 },
136
+ playable: { type: Boolean, default: !0 },
137
+ multiple: { type: Boolean },
138
+ urlSmall: {}
139
+ },
140
+ setup(v, { expose: w }) {
141
+ const e = v, t = `${f}-player-wrapper`, o = `${f}-player-poster`, P = `${f}-player-btn`, T = `${f}-player-btn-text`, g = `${f}-player-icon`, m = d(), _ = d(), a = d(), n = d(!1), k = (l) => {
142
+ l.stopPropagation(), e.playable && (n.value = !0, setTimeout(() => {
143
+ var u;
144
+ (u = a.value) == null || u.play();
145
+ }, 0));
146
+ }, r = () => {
147
+ n.value = !1;
148
+ };
149
+ let s = null;
150
+ return L(() => {
151
+ !e.autoPlay && m.value && (s = new IntersectionObserver(
152
+ ([l]) => {
153
+ l.isIntersecting && (n.value = !0);
154
+ },
155
+ { threshold: 0.1 }
156
+ ), s.observe(m.value));
157
+ }), E(() => {
158
+ s == null || s.disconnect();
159
+ }), w({
160
+ play() {
161
+ var l;
162
+ e.autoPlay ? (l = _.value) == null || l.play() : k(new MouseEvent("click"));
163
+ },
164
+ pause() {
165
+ var l, u;
166
+ (l = _.value) == null || l.pause(), (u = a.value) == null || u.pause();
167
+ }
168
+ }), (l, u) => e.autoPlay ? (c(), x(I, V({ key: 0 }, e, {
169
+ url: e.url,
170
+ ref_key: "videoRef",
171
+ ref: _
172
+ }), null, 16, ["url"])) : (c(), C(
173
+ O,
174
+ { key: 1 },
175
+ [
176
+ i(
177
+ "div",
178
+ {
179
+ class: y([t, e.class]),
180
+ style: U(e.style)
181
+ },
182
+ [
183
+ e.poster ? (c(), x(W(j), {
184
+ key: 0,
185
+ class: y(o),
186
+ src: e.poster,
187
+ alt: "AITO"
188
+ }, null, 8, ["src"])) : R("v-if", !0),
189
+ i(
190
+ "button",
191
+ {
192
+ ref_key: "btnRef",
193
+ ref: m,
194
+ class: y([P, e.playerButtonClass]),
195
+ onClick: k
196
+ },
197
+ [
198
+ b(l.$slots, "play", {}, () => [
199
+ (c(), C("svg", {
200
+ class: y(g),
201
+ viewBox: "0 0 1024 1024",
202
+ version: "1.1",
203
+ xmlns: "http://www.w3.org/2000/svg",
204
+ width: "200",
205
+ height: "200"
206
+ }, [...u[0] || (u[0] = [
207
+ i(
208
+ "path",
209
+ {
210
+ d: "M671.744 495.616c20.48 12.288 20.48 36.864 0 49.152l-217.088 126.976c-20.48 12.288-45.056-4.096-45.056-24.576V393.216c0-20.48 24.576-36.864 45.056-24.576l217.088 126.976z",
211
+ fill: "#ffffff"
212
+ },
213
+ null,
214
+ -1
215
+ /* CACHED */
216
+ ),
217
+ i(
218
+ "path",
219
+ {
220
+ d: "M512 1011.712C237.568 1011.712 12.288 786.432 12.288 512 12.288 237.568 237.568 12.288 512 12.288c274.432 0 499.712 225.28 499.712 499.712 0 274.432-225.28 499.712-499.712 499.712z m0-958.464c-253.952 0-458.752 204.8-458.752 458.752s204.8 458.752 458.752 458.752 458.752-204.8 458.752-458.752-204.8-458.752-458.752-458.752z",
221
+ fill: "#ffffff"
222
+ },
223
+ null,
224
+ -1
225
+ /* CACHED */
226
+ )
227
+ ])])),
228
+ i(
229
+ "span",
230
+ {
231
+ class: y(T)
232
+ },
233
+ H(e.playerButtonText),
234
+ 1
235
+ /* TEXT */
236
+ )
237
+ ])
238
+ ],
239
+ 2
240
+ /* CLASS */
241
+ )
242
+ ],
243
+ 6
244
+ /* CLASS, STYLE */
245
+ ),
246
+ n.value ? (c(), x(Y, {
247
+ key: 0,
248
+ to: "body"
249
+ }, [
250
+ z(
251
+ I,
252
+ V(e, {
253
+ autoPlay: !1,
254
+ ref_key: "modalVideoRef",
255
+ ref: a,
256
+ onPaused: r
257
+ }),
258
+ {
259
+ close: $(() => [
260
+ b(l.$slots, "close")
261
+ ]),
262
+ _: 3
263
+ /* FORWARDED */
264
+ },
265
+ 16
266
+ /* FULL_PROPS */
267
+ )
268
+ ])) : R("v-if", !0)
269
+ ],
270
+ 64
271
+ /* STABLE_FRAGMENT */
272
+ ));
273
+ }
274
+ }), q = /* @__PURE__ */ S({
275
+ __name: "video-multiple",
128
276
  props: {
129
277
  class: {},
130
278
  style: {},
@@ -137,137 +285,200 @@ const D = ["controls", "poster", "src"], z = /* @__PURE__ */ L({
137
285
  multiple: { type: Boolean },
138
286
  urlSmall: {}
139
287
  },
140
- setup(m) {
141
- const e = m, C = `${u}-player-wrapper`, l = `${u}-player-poster`, k = `${u}-player-btn`, g = `${u}-player-btn-text`, x = `${u}-player-icon`, w = d(), B = d(), b = d(), t = (o) => {
142
- var v, P;
143
- o.stopPropagation(), (v = b.value) == null || v.pause(), (P = B.value) == null || P.play();
144
- }, s = () => {
145
- var o;
146
- (o = b.value) == null || o.play();
288
+ setup(v, { expose: w }) {
289
+ const e = v, t = `${f}-player-wrapper`, o = `${f}-player-btn`, P = `${f}-player-btn-text`, T = `${f}-player-icon`, g = d(), m = d(), _ = d(), a = d(!1), n = (s) => {
290
+ var l;
291
+ s.stopPropagation(), e.playable && ((l = m.value) == null || l.pause(), a.value = !0, setTimeout(() => {
292
+ var u;
293
+ (u = _.value) == null || u.play();
294
+ }, 0));
295
+ }, k = () => {
296
+ var s;
297
+ a.value = !1, (s = m.value) == null || s.play();
147
298
  };
148
- let p = null;
149
- const n = d(!1);
150
- return O(() => {
151
- p = new IntersectionObserver(
152
- ([o]) => {
153
- o.isIntersecting && (n.value = !0);
299
+ let r = null;
300
+ return L(() => {
301
+ g.value && (r = new IntersectionObserver(
302
+ ([s]) => {
303
+ s.isIntersecting && (a.value = !0);
154
304
  },
155
305
  { threshold: 0.1 }
156
- ), w.value && p.observe(w.value);
157
- }), U(() => {
158
- p == null || p.disconnect();
159
- }), (o, v) => (r(), h(
160
- S,
306
+ ), r.observe(g.value));
307
+ }), E(() => {
308
+ r == null || r.disconnect();
309
+ }), w({
310
+ play() {
311
+ n(new MouseEvent("click"));
312
+ },
313
+ pause() {
314
+ var s, l;
315
+ (s = m.value) == null || s.pause(), (l = _.value) == null || l.pause();
316
+ }
317
+ }), (s, l) => (c(), C(
318
+ O,
161
319
  null,
162
320
  [
163
- e.autoPlay || e.multiple ? (r(), $(z, T({ key: 0 }, e, {
164
- url: e.multiple && e.urlSmall || e.url,
165
- ref_key: "autoPlayRef",
166
- ref: b
167
- }), null, 16, ["url"])) : _("v-if", !0),
168
- !e.autoPlay || e.multiple ? (r(), h(
169
- S,
170
- { key: 1 },
321
+ R(" Background: Small Video AutoPlay "),
322
+ z(I, V(e, {
323
+ url: e.urlSmall || e.url,
324
+ autoPlay: !0,
325
+ ref_key: "smallVideoRef",
326
+ ref: m
327
+ }), null, 16, ["url"]),
328
+ R(" Foreground: Button -> Modal Video (Large) "),
329
+ i(
330
+ "div",
331
+ {
332
+ class: y([t, e.class, "is-multiple"]),
333
+ style: U(e.style)
334
+ },
171
335
  [
172
- y(
173
- "div",
336
+ i(
337
+ "button",
174
338
  {
175
- class: f([C, e.class, { "is-multiple": e.multiple }]),
176
- style: H(e.style)
339
+ ref_key: "btnRef",
340
+ ref: g,
341
+ class: y([o, e.playerButtonClass]),
342
+ onClick: n
177
343
  },
178
344
  [
179
- e.poster ? (r(), $(N(j), {
180
- key: 0,
181
- class: f(l),
182
- src: e.poster,
183
- alt: "AITO"
184
- }, null, 8, ["src"])) : _("v-if", !0),
185
- y(
186
- "button",
187
- {
188
- ref_key: "btnRef",
189
- ref: w,
190
- class: f([k, e.playerButtonClass]),
191
- onClick: t
192
- },
193
- [
194
- V(o.$slots, "play", {}, () => [
195
- (r(), h("svg", {
196
- class: f(x),
197
- viewBox: "0 0 1024 1024",
198
- version: "1.1",
199
- xmlns: "http://www.w3.org/2000/svg",
200
- width: "200",
201
- height: "200"
202
- }, [...v[0] || (v[0] = [
203
- y(
204
- "path",
205
- {
206
- d: "M671.744 495.616c20.48 12.288 20.48 36.864 0 49.152l-217.088 126.976c-20.48 12.288-45.056-4.096-45.056-24.576V393.216c0-20.48 24.576-36.864 45.056-24.576l217.088 126.976z",
207
- fill: "#ffffff"
208
- },
209
- null,
210
- -1
211
- /* CACHED */
212
- ),
213
- y(
214
- "path",
215
- {
216
- d: "M512 1011.712C237.568 1011.712 12.288 786.432 12.288 512 12.288 237.568 237.568 12.288 512 12.288c274.432 0 499.712 225.28 499.712 499.712 0 274.432-225.28 499.712-499.712 499.712z m0-958.464c-253.952 0-458.752 204.8-458.752 458.752s204.8 458.752 458.752 458.752 458.752-204.8 458.752-458.752-204.8-458.752-458.752-458.752z",
217
- fill: "#ffffff"
218
- },
219
- null,
220
- -1
221
- /* CACHED */
222
- )
223
- ])])),
224
- y(
225
- "span",
226
- {
227
- class: f(g)
228
- },
229
- X(e.playerButtonText),
230
- 1
231
- /* TEXT */
232
- )
233
- ])
234
- ],
235
- 2
236
- /* CLASS */
237
- )
345
+ b(s.$slots, "play", {}, () => [
346
+ (c(), C("svg", {
347
+ class: y(T),
348
+ viewBox: "0 0 1024 1024",
349
+ version: "1.1",
350
+ xmlns: "http://www.w3.org/2000/svg",
351
+ width: "200",
352
+ height: "200"
353
+ }, [...l[0] || (l[0] = [
354
+ i(
355
+ "path",
356
+ {
357
+ d: "M671.744 495.616c20.48 12.288 20.48 36.864 0 49.152l-217.088 126.976c-20.48 12.288-45.056-4.096-45.056-24.576V393.216c0-20.48 24.576-36.864 45.056-24.576l217.088 126.976z",
358
+ fill: "#ffffff"
359
+ },
360
+ null,
361
+ -1
362
+ /* CACHED */
363
+ ),
364
+ i(
365
+ "path",
366
+ {
367
+ d: "M512 1011.712C237.568 1011.712 12.288 786.432 12.288 512 12.288 237.568 237.568 12.288 512 12.288c274.432 0 499.712 225.28 499.712 499.712 0 274.432-225.28 499.712-499.712 499.712z m0-958.464c-253.952 0-458.752 204.8-458.752 458.752s204.8 458.752 458.752 458.752 458.752-204.8 458.752-458.752-204.8-458.752-458.752-458.752-458.752z",
368
+ fill: "#ffffff"
369
+ },
370
+ null,
371
+ -1
372
+ /* CACHED */
373
+ )
374
+ ])])),
375
+ i(
376
+ "span",
377
+ {
378
+ class: y(P)
379
+ },
380
+ H(e.playerButtonText),
381
+ 1
382
+ /* TEXT */
383
+ )
384
+ ])
238
385
  ],
239
- 6
240
- /* CLASS, STYLE */
241
- ),
242
- n.value ? (r(), $(F, {
243
- key: 0,
244
- to: "body"
245
- }, [
246
- Y(
247
- z,
248
- T(e, {
249
- autoPlay: !1,
250
- ref_key: "vwRef",
251
- ref: B,
252
- onPaused: s
253
- }),
254
- null,
255
- 16
256
- /* FULL_PROPS */
257
- )
258
- ])) : _("v-if", !0)
386
+ 2
387
+ /* CLASS */
388
+ )
259
389
  ],
260
- 64
261
- /* STABLE_FRAGMENT */
262
- )) : _("v-if", !0)
390
+ 6
391
+ /* CLASS, STYLE */
392
+ ),
393
+ a.value ? (c(), x(Y, {
394
+ key: 0,
395
+ to: "body"
396
+ }, [
397
+ z(I, V(e, {
398
+ url: e.url,
399
+ autoPlay: !1,
400
+ ref_key: "modalVideoRef",
401
+ ref: _,
402
+ onPaused: k
403
+ }), {
404
+ close: $(() => [
405
+ b(s.$slots, "close")
406
+ ]),
407
+ _: 3
408
+ /* FORWARDED */
409
+ }, 16, ["url"])
410
+ ])) : R("v-if", !0)
263
411
  ],
264
412
  64
265
413
  /* STABLE_FRAGMENT */
266
414
  ));
267
415
  }
416
+ }), M = /* @__PURE__ */ S({
417
+ __name: "video",
418
+ props: {
419
+ class: {},
420
+ style: {},
421
+ playerButtonClass: {},
422
+ playerButtonText: { default: "PLAY" },
423
+ poster: { default: "" },
424
+ url: {},
425
+ autoPlay: { type: Boolean, default: !0 },
426
+ playable: { type: Boolean, default: !0 },
427
+ multiple: { type: Boolean },
428
+ urlSmall: {}
429
+ },
430
+ setup(v, { expose: w }) {
431
+ const e = v, t = d();
432
+ return w({
433
+ play() {
434
+ var o;
435
+ (o = t.value) == null || o.play();
436
+ },
437
+ pause() {
438
+ var o;
439
+ (o = t.value) == null || o.pause();
440
+ }
441
+ }), (o, P) => e.multiple ? (c(), x(
442
+ q,
443
+ V({ key: 0 }, e, {
444
+ ref_key: "videoRef",
445
+ ref: t
446
+ }),
447
+ {
448
+ play: $(() => [
449
+ b(o.$slots, "play")
450
+ ]),
451
+ close: $(() => [
452
+ b(o.$slots, "close")
453
+ ]),
454
+ _: 3
455
+ /* FORWARDED */
456
+ },
457
+ 16
458
+ /* FULL_PROPS */
459
+ )) : (c(), x(
460
+ G,
461
+ V({ key: 1 }, e, {
462
+ ref_key: "videoRef",
463
+ ref: t
464
+ }),
465
+ {
466
+ play: $(() => [
467
+ b(o.$slots, "play")
468
+ ]),
469
+ close: $(() => [
470
+ b(o.$slots, "close")
471
+ ]),
472
+ _: 3
473
+ /* FORWARDED */
474
+ },
475
+ 16
476
+ /* FULL_PROPS */
477
+ ));
478
+ }
268
479
  });
269
- R.install = (m) => (m.component("ScVideo", R), m);
270
- const J = R;
480
+ M.install = (v) => (v.component("ScVideo", M), v);
481
+ const Z = M;
271
482
  export {
272
- J as ScVideo
483
+ Z as ScVideo
273
484
  };