jeawin-astro 3.0.38 → 3.0.40

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": "jeawin-astro",
3
- "version": "3.0.38",
3
+ "version": "3.0.40",
4
4
  "author": "chaegumi <chaegumi@qq.com>",
5
5
  "description": "",
6
6
  "license": "MIT",
@@ -15,6 +15,7 @@ import Youtube from "./youtube.astro";
15
15
  import Vimeo from "./vimeo.astro";
16
16
  import { img_add_link, render_value,img_change_attrs } from "../scripts/util.js";
17
17
  import view360img from "../assets/images/360_view.svg";
18
+ import IframeVideo from "./iframe_video.astro";
18
19
 
19
20
  type JWVIDEO = {
20
21
  poster: string; // 图片
@@ -40,6 +41,12 @@ const { node_title, nodepics = [], video, view360 } = Astro.props;
40
41
  x-data={`{
41
42
  isVideoPoppedUp:false,
42
43
  closeVideo(){
44
+ if(this.$refs.video){
45
+ const iframe = this.$refs.video.querySelector('iframe');
46
+ if(iframe){
47
+ iframe.src = iframe.src;
48
+ }
49
+ }
43
50
  this.isVideoPoppedUp = false;
44
51
  },
45
52
  openVideo(){
@@ -150,7 +157,7 @@ const { node_title, nodepics = [], video, view360 } = Astro.props;
150
157
  </swiper-container>
151
158
  {
152
159
  video ? (
153
- <div
160
+ <div x-ref="video"
154
161
  x-bind:class="{ 'flex': isVideoPoppedUp, 'hidden': !isVideoPoppedUp }"
155
162
  class="fixed inset-0 w-full h-full flex items-center justify-center hidden z-10"
156
163
  >
@@ -186,17 +193,7 @@ const { node_title, nodepics = [], video, view360 } = Astro.props;
186
193
  ) : video.platform == 'vimeo' ? (
187
194
  <Vimeo id={render_value(video, 'id')} />
188
195
  ) : (
189
- <iframe
190
- x-ref="video"
191
- width="560"
192
- height="315"
193
- src={video.id}
194
- title="video player"
195
- frameborder="0"
196
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
197
- referrerpolicy="strict-origin-when-cross-origin"
198
- allowfullscreen>
199
- </iframe>
196
+ <IframeVideo id={render_value(video, 'id')} />
200
197
  )
201
198
  }
202
199
  </Fragment>
@@ -206,7 +203,7 @@ const { node_title, nodepics = [], video, view360 } = Astro.props;
206
203
  ) : video.type == 'code' ? (
207
204
  <Fragment set:html={video.code} />
208
205
  ) : (
209
- <video x-ref="video" class="rounded-lg w-full max-w-2xl" controls>
206
+ <video class="rounded-lg w-full max-w-2xl" controls>
210
207
  <source src={video.local_url} type="video/mp4" />
211
208
  </video>
212
209
  )
@@ -0,0 +1,18 @@
1
+ ---
2
+ const {wrapper_class, inner_class} = Astro.props
3
+ ---
4
+ <!-- 图片翻转卡片 -->
5
+ <div class:list={["w-full h-full perspective-midrange", wrapper_class]} data-aos="flip-left">
6
+ <div class:list={["relative !w-full !h-full text-center transition-transform transform-3d duration-700 hover:rotate-y-180", inner_class]}>
7
+ <div class="absolute w-full h-full backface-hidden flex items-center justify-center">
8
+ <slot name="flip-card-front-html">
9
+ <p>正面内容</p>
10
+ </slot>
11
+ </div>
12
+ <div class="absolute w-full h-full backface-hidden flex items-center justify-center rotate-y-180">
13
+ <slot name="flip-card-back-html">
14
+ <p>背面内容</p>
15
+ </slot>
16
+ </div>
17
+ </div>
18
+ </div>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import dayjs from 'dayjs';
3
+ const { id, width = 560, height = 315, title = 'Video player' } = Astro.props;
4
+ let url = id;
5
+
6
+ const currenttime = dayjs().unix();
7
+ ---
8
+
9
+ <div id={`iframe-video-placeholder${currenttime}`} style={`width:${width}px;height:${height}px;`}></div>
10
+
11
+ <script is:inline define:vars={{currenttime, url: url, width, height, title}}>
12
+ window.addEventListener('load', function() {
13
+ let iframe = document.createElement('iframe');
14
+ iframe.src = url;
15
+ iframe.width = width;
16
+ iframe.height = height;
17
+ iframe.title = title;
18
+ iframe.allowFullscreen = true;
19
+ document.getElementById(`iframe-video-placeholder${currenttime}`).appendChild(iframe);
20
+ });
21
+ </script>
@@ -57,7 +57,9 @@ export {default as Tabs} from "./tabs.astro";
57
57
  export {default as TagsCategoryList} from "./tags_category_list.astro";
58
58
  export {default as Vimeo} from "./vimeo.astro";
59
59
  export {default as Youtube} from "./youtube.astro";
60
+ export {default as IframeVideo} from "./iframe_video.astro";
60
61
  export {default as Chatbot} from "./chatbot.astro";
62
+ export {default as FlipCard} from "./flip_card.astro";
61
63
 
62
64
  export * from "./bgs/index.ts";
63
65
  export * from "./blocks/index.ts";
@@ -1,5 +1,6 @@
1
1
  ---
2
- const { id } = Astro.props;
2
+ import dayjs from 'dayjs';
3
+ const { id, width = 640, height = 360, title = 'Vimeo player' } = Astro.props;
3
4
  let url = "";
4
5
  if (id.indexOf("https") !== -1) {
5
6
  // 是url形式
@@ -8,12 +9,18 @@ if (id.indexOf("https") !== -1) {
8
9
  // 是id形式
9
10
  url = `https://player.vimeo.com/video/${id}`;
10
11
  }
12
+ const currenttime = dayjs().unix();
11
13
  ---
14
+ <div id={`vimeo-placeholder${currenttime}`} style={`width:${width}px;height:${height}px;`}></div>
12
15
 
13
- <iframe
14
- title="vimeo-player"
15
- src={url}
16
- width="640"
17
- height="360"
18
- frameborder="0"
19
- allowfullscreen></iframe>
16
+ <script is:inline define:vars={{currenttime, url: url, width, height, title}}>
17
+ window.addEventListener('load', function() {
18
+ let iframe = document.createElement('iframe');
19
+ iframe.src = url;
20
+ iframe.width = width;
21
+ iframe.height = height;
22
+ iframe.title = title;
23
+ iframe.allowFullscreen = true;
24
+ document.getElementById(`vimeo-placeholder${currenttime}`).appendChild(iframe);
25
+ });
26
+ </script>
@@ -1,5 +1,6 @@
1
1
  ---
2
- const { id } = Astro.props;
2
+ import dayjs from 'dayjs';
3
+ const { id, width = 560, height = 315, title = 'Youtube video player' } = Astro.props;
3
4
  let url = "";
4
5
  if (id.indexOf("https") !== -1) {
5
6
  // 是url形式
@@ -8,14 +9,20 @@ if (id.indexOf("https") !== -1) {
8
9
  // 是id形式
9
10
  url = `https://www.youtube.com/embed/${id}`;
10
11
  }
12
+
13
+ const currenttime = dayjs().unix();
11
14
  ---
12
15
 
13
- <iframe
14
- width="560"
15
- height="315"
16
- src={url}
17
- title="YouTube video player"
18
- frameborder="0"
19
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
20
- referrerpolicy="strict-origin-when-cross-origin"
21
- allowfullscreen></iframe>
16
+ <div id={`youtube-placeholder${currenttime}`} style={`width:${width}px;height:${height}px;`}></div>
17
+
18
+ <script is:inline define:vars={{currenttime, url: url, width, height, title}}>
19
+ window.addEventListener('load', function() {
20
+ let iframe = document.createElement('iframe');
21
+ iframe.src = url;
22
+ iframe.width = width;
23
+ iframe.height = height;
24
+ iframe.title = title;
25
+ iframe.allowFullscreen = true;
26
+ document.getElementById(`youtube-placeholder${currenttime}`).appendChild(iframe);
27
+ });
28
+ </script>