pb-sxp-ui 1.0.19 → 1.0.21

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
@@ -12237,7 +12237,7 @@ const FingerSwipeTip = ({ imageUrl }) => {
12237
12237
  * @Author: binruan@chatlabs.com
12238
12238
  * @Date: 2024-03-20 10:27:31
12239
12239
  * @LastEditors: binruan@chatlabs.com
12240
- * @LastEditTime: 2024-04-17 15:37:47
12240
+ * @LastEditTime: 2024-04-17 18:09:29
12241
12241
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12242
12242
  *
12243
12243
  */
@@ -12245,28 +12245,26 @@ const Picture = (props) => {
12245
12245
  const { src, height, width } = props;
12246
12246
  const [blur, setBlur] = React.useState(false);
12247
12247
  const { sxpParameter } = useSxpDataSource();
12248
- React.useEffect(() => {
12249
- if (src === '' || !src)
12250
- return;
12251
- const img = new Image();
12252
- img.src = `${src}?imageMogr2/format/jpg`;
12253
- img.onload = () => {
12254
- const aspectRatio = img.height / img.width;
12255
- const targetAspectRatio = 16 / 9;
12256
- const tolerance = 0.05; // 允许的宽高比误差范围
12257
- if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
12258
- setBlur(true);
12259
- }
12260
- };
12261
- }, [src]);
12248
+ const onLoad = (img) => {
12249
+ const aspectRatio = img.height / img.width;
12250
+ const targetAspectRatio = 16 / 9;
12251
+ const tolerance = 0.05; // 允许的宽高比误差范围
12252
+ if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
12253
+ setBlur(true);
12254
+ }
12255
+ };
12262
12256
  const getImg = React.useCallback((src, style) => {
12263
12257
  if (src === '' || !src)
12264
12258
  return;
12265
- return (React.createElement("picture", null,
12266
- React.createElement("source", { type: 'image/avif', srcSet: `${src}?imageMogr2/format/avif` }),
12259
+ return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
12260
+ React.createElement("source", { type: 'image/avif', srcSet: src }),
12267
12261
  React.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
12268
12262
  React.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
12269
- React.createElement("img", { loading: 'lazy', src: src, style: style })));
12263
+ React.createElement("img", { src: src, style: style, onLoad: (e) => {
12264
+ onLoad(e.target);
12265
+ } }))) : (React.createElement("img", { src: src, style: style, onLoad: (e) => {
12266
+ onLoad(e.target);
12267
+ } }));
12270
12268
  }, []);
12271
12269
  return (React.createElement("div", { style: {
12272
12270
  overflow: 'hidden',