pb-sxp-ui 1.0.63 → 1.0.64

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/index.js CHANGED
@@ -7,7 +7,6 @@ import EventEmitter from 'eventemitter3';
7
7
  import { css } from '@emotion/css';
8
8
  import { BetaSchemaForm } from '@ant-design/pro-components';
9
9
  import * as ReactDOM from 'react-dom';
10
- import Hls from 'hls.js';
11
10
 
12
11
  /******************************************************************************
13
12
  Copyright (c) Microsoft Corporation.
@@ -8369,7 +8368,7 @@ var ExpandableText$1 = memo(ExpandableText);
8369
8368
  * @Author: binruan@chatlabs.com
8370
8369
  * @Date: 2024-03-20 10:27:31
8371
8370
  * @LastEditors: binruan@chatlabs.com
8372
- * @LastEditTime: 2024-04-19 14:12:55
8371
+ * @LastEditTime: 2024-05-17 16:53:11
8373
8372
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8374
8373
  *
8375
8374
  */
@@ -8381,10 +8380,32 @@ const FormatImage = forwardRef((props, ref) => {
8381
8380
  setImgSrc(v);
8382
8381
  }
8383
8382
  }));
8383
+ // useEffect(() => {
8384
+ // setImgSrc(src);
8385
+ // }, [src]);
8386
+ const imgRef = useRef(null);
8384
8387
  useEffect(() => {
8385
- setImgSrc(src);
8388
+ let observer = null;
8389
+ const { current } = imgRef;
8390
+ if (current) {
8391
+ observer = new IntersectionObserver((entries) => {
8392
+ entries.forEach((entry) => {
8393
+ if (entry.isIntersecting) {
8394
+ setImgSrc(src);
8395
+ observer.unobserve(current);
8396
+ }
8397
+ });
8398
+ }, { threshold: 0.1 } // 触发阈值,可根据需要调整
8399
+ );
8400
+ observer.observe(current);
8401
+ }
8402
+ return () => {
8403
+ if (observer && current) {
8404
+ observer.unobserve(current);
8405
+ }
8406
+ };
8386
8407
  }, [src]);
8387
- return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8408
+ return (React.createElement("div", { ref: imgRef }, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8388
8409
  React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8389
8410
  React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8390
8411
  React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
@@ -12291,6 +12312,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12291
12312
  const videoSrc = rec.video.url;
12292
12313
  if (!videoSrc)
12293
12314
  return;
12315
+ videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12294
12316
  setIsPauseVideo(false);
12295
12317
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
12296
12318
  const dom = document.querySelector('#player-container-id');
@@ -12298,7 +12320,6 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12298
12320
  if (!dom && !dom2)
12299
12321
  return;
12300
12322
  videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
12301
- videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12302
12323
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
12303
12324
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
12304
12325
  // videoRef?.on('canplay', handleCanplay);
@@ -13371,8 +13392,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
13371
13392
  if (!videoRef.current.src) {
13372
13393
  const videoSrc = rec.video.url;
13373
13394
  if (videoSrc.includes('.m3u8')) {
13374
- if (Hls.isSupported()) {
13375
- const hls = new Hls();
13395
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.Hls.isSupported())) {
13396
+ const hls = new window.Hls();
13376
13397
  hls.loadSource(videoSrc);
13377
13398
  hls.attachMedia(videoRef.current);
13378
13399
  }