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.cjs CHANGED
@@ -11,7 +11,6 @@ var EventEmitter = require('eventemitter3');
11
11
  var css = require('@emotion/css');
12
12
  var proComponents = require('@ant-design/pro-components');
13
13
  var ReactDOM = require('react-dom');
14
- var Hls = require('hls.js');
15
14
 
16
15
  function _interopNamespaceDefault(e) {
17
16
  var n = Object.create(null);
@@ -8392,7 +8391,7 @@ var ExpandableText$1 = React.memo(ExpandableText);
8392
8391
  * @Author: binruan@chatlabs.com
8393
8392
  * @Date: 2024-03-20 10:27:31
8394
8393
  * @LastEditors: binruan@chatlabs.com
8395
- * @LastEditTime: 2024-04-19 14:12:55
8394
+ * @LastEditTime: 2024-05-17 16:53:11
8396
8395
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8397
8396
  *
8398
8397
  */
@@ -8404,10 +8403,32 @@ const FormatImage = React.forwardRef((props, ref) => {
8404
8403
  setImgSrc(v);
8405
8404
  }
8406
8405
  }));
8406
+ // useEffect(() => {
8407
+ // setImgSrc(src);
8408
+ // }, [src]);
8409
+ const imgRef = React.useRef(null);
8407
8410
  React.useEffect(() => {
8408
- setImgSrc(src);
8411
+ let observer = null;
8412
+ const { current } = imgRef;
8413
+ if (current) {
8414
+ observer = new IntersectionObserver((entries) => {
8415
+ entries.forEach((entry) => {
8416
+ if (entry.isIntersecting) {
8417
+ setImgSrc(src);
8418
+ observer.unobserve(current);
8419
+ }
8420
+ });
8421
+ }, { threshold: 0.1 } // 触发阈值,可根据需要调整
8422
+ );
8423
+ observer.observe(current);
8424
+ }
8425
+ return () => {
8426
+ if (observer && current) {
8427
+ observer.unobserve(current);
8428
+ }
8429
+ };
8409
8430
  }, [src]);
8410
- return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8431
+ return (React.createElement("div", { ref: imgRef }, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8411
8432
  React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8412
8433
  React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8413
8434
  React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
@@ -12314,6 +12335,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12314
12335
  const videoSrc = rec.video.url;
12315
12336
  if (!videoSrc)
12316
12337
  return;
12338
+ videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12317
12339
  setIsPauseVideo(false);
12318
12340
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
12319
12341
  const dom = document.querySelector('#player-container-id');
@@ -12321,7 +12343,6 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12321
12343
  if (!dom && !dom2)
12322
12344
  return;
12323
12345
  videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
12324
- videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12325
12346
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
12326
12347
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
12327
12348
  // videoRef?.on('canplay', handleCanplay);
@@ -13394,8 +13415,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
13394
13415
  if (!videoRef.current.src) {
13395
13416
  const videoSrc = rec.video.url;
13396
13417
  if (videoSrc.includes('.m3u8')) {
13397
- if (Hls.isSupported()) {
13398
- const hls = new Hls();
13418
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.Hls.isSupported())) {
13419
+ const hls = new window.Hls();
13399
13420
  hls.loadSource(videoSrc);
13400
13421
  hls.attachMedia(videoRef.current);
13401
13422
  }