pb-sxp-ui 1.0.14 → 1.0.15
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 +17 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +17 -10
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/Picture.js +8 -5
- package/es/core/components/SxpPageRender/index.js +1 -1
- package/es/core/utils/localStore.d.ts +1 -0
- package/es/core/utils/localStore.js +6 -2
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +7 -4
- package/lib/core/components/SxpPageRender/index.js +1 -1
- package/lib/core/utils/localStore.d.ts +1 -0
- package/lib/core/utils/localStore.js +7 -3
- package/package.json +1 -1
@@ -1,10 +1,13 @@
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
2
2
|
import { useSxpDataSource } from '../../../../core/hooks';
|
3
3
|
const Picture = (props) => {
|
4
4
|
const { src, height, width } = props;
|
5
5
|
const [blur, setBlur] = useState(false);
|
6
6
|
const imgDom = useRef(null);
|
7
7
|
const { sxpParameter } = useSxpDataSource();
|
8
|
+
const getAvifToPng = useCallback((src) => {
|
9
|
+
return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/png` : src;
|
10
|
+
}, []);
|
8
11
|
useEffect(() => {
|
9
12
|
if (imgDom.current === null || src === '') {
|
10
13
|
return;
|
@@ -19,22 +22,22 @@ const Picture = (props) => {
|
|
19
22
|
setBlur(true);
|
20
23
|
}
|
21
24
|
};
|
22
|
-
imgDom.current.src = src;
|
23
|
-
}, [src]);
|
25
|
+
imgDom.current.src = getAvifToPng(src);
|
26
|
+
}, [src, getAvifToPng]);
|
24
27
|
return (React.createElement("div", { style: {
|
25
28
|
overflow: 'hidden',
|
26
29
|
height,
|
27
30
|
width: '100%',
|
28
31
|
position: 'relative'
|
29
32
|
} },
|
30
|
-
React.createElement("img", { ref: imgDom, loading: 'lazy', src: src
|
33
|
+
React.createElement("img", { ref: imgDom, loading: 'lazy', src: src ? getAvifToPng(src) : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
|
31
34
|
height: '100%',
|
32
35
|
width: '100%',
|
33
36
|
objectFit: 'cover',
|
34
37
|
filter: blur ? 'blur(10px)' : 'none',
|
35
38
|
transform: blur ? 'scale(1.2)' : 'none'
|
36
39
|
} }),
|
37
|
-
blur && (React.createElement("img", { ref: imgDom, src: src, loading: 'lazy', style: {
|
40
|
+
blur && (React.createElement("img", { ref: imgDom, src: getAvifToPng(src), loading: 'lazy', style: {
|
38
41
|
width: '100%',
|
39
42
|
objectFit: 'contain',
|
40
43
|
position: 'absolute',
|
@@ -35,7 +35,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
35
35
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
36
36
|
const { productView } = useEventReport();
|
37
37
|
const isShowFingerTip = useMemo(() => {
|
38
|
-
return data.length > 0 && !loading &&
|
38
|
+
return data.length > 0 && !loading && getFeUserId();
|
39
39
|
}, [data, loading]);
|
40
40
|
const handleH5EnterLink = useCallback(() => {
|
41
41
|
if (data.length <= 0) {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export declare const FAKE_USER_KEY = "SXP_FAKE_USER_ID";
|
2
|
+
export declare const FAKE_USER_STATE = "FAKE_USER_STATE";
|
2
3
|
export declare const storeAndLoadFeUserId: () => string;
|
3
4
|
export declare const removeFeUserId: () => void;
|
4
5
|
export declare const getFeUserId: () => boolean;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { isEmpty } from 'lodash';
|
2
2
|
import { uuid } from './tool';
|
3
3
|
export const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
|
4
|
+
export const FAKE_USER_STATE = 'FAKE_USER_STATE';
|
4
5
|
export const storeAndLoadFeUserId = () => {
|
5
6
|
let fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
|
6
7
|
if (isEmpty(fakeUserId)) {
|
@@ -13,6 +14,9 @@ export const removeFeUserId = () => {
|
|
13
14
|
window.localStorage.removeItem(FAKE_USER_KEY);
|
14
15
|
};
|
15
16
|
export const getFeUserId = () => {
|
16
|
-
const
|
17
|
-
|
17
|
+
const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
|
18
|
+
if (isEmpty(fakeUserState)) {
|
19
|
+
window.localStorage.setItem(FAKE_USER_STATE, 'true');
|
20
|
+
}
|
21
|
+
return isEmpty(fakeUserState);
|
18
22
|
};
|
@@ -8,6 +8,9 @@ const Picture = (props) => {
|
|
8
8
|
const [blur, setBlur] = (0, react_1.useState)(false);
|
9
9
|
const imgDom = (0, react_1.useRef)(null);
|
10
10
|
const { sxpParameter } = (0, hooks_1.useSxpDataSource)();
|
11
|
+
const getAvifToPng = (0, react_1.useCallback)((src) => {
|
12
|
+
return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/png` : src;
|
13
|
+
}, []);
|
11
14
|
(0, react_1.useEffect)(() => {
|
12
15
|
if (imgDom.current === null || src === '') {
|
13
16
|
return;
|
@@ -22,22 +25,22 @@ const Picture = (props) => {
|
|
22
25
|
setBlur(true);
|
23
26
|
}
|
24
27
|
};
|
25
|
-
imgDom.current.src = src;
|
26
|
-
}, [src]);
|
28
|
+
imgDom.current.src = getAvifToPng(src);
|
29
|
+
}, [src, getAvifToPng]);
|
27
30
|
return (react_1.default.createElement("div", { style: {
|
28
31
|
overflow: 'hidden',
|
29
32
|
height,
|
30
33
|
width: '100%',
|
31
34
|
position: 'relative'
|
32
35
|
} },
|
33
|
-
react_1.default.createElement("img", { ref: imgDom, loading: 'lazy', src: src
|
36
|
+
react_1.default.createElement("img", { ref: imgDom, loading: 'lazy', src: src ? getAvifToPng(src) : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
|
34
37
|
height: '100%',
|
35
38
|
width: '100%',
|
36
39
|
objectFit: 'cover',
|
37
40
|
filter: blur ? 'blur(10px)' : 'none',
|
38
41
|
transform: blur ? 'scale(1.2)' : 'none'
|
39
42
|
} }),
|
40
|
-
blur && (react_1.default.createElement("img", { ref: imgDom, src: src, loading: 'lazy', style: {
|
43
|
+
blur && (react_1.default.createElement("img", { ref: imgDom, src: getAvifToPng(src), loading: 'lazy', style: {
|
41
44
|
width: '100%',
|
42
45
|
objectFit: 'contain',
|
43
46
|
position: 'absolute',
|
@@ -38,7 +38,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
38
38
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = (0, hooks_1.useSxpDataSource)();
|
39
39
|
const { productView } = (0, useEventReport_1.useEventReport)();
|
40
40
|
const isShowFingerTip = (0, react_1.useMemo)(() => {
|
41
|
-
return data.length > 0 && !loading &&
|
41
|
+
return data.length > 0 && !loading && (0, localStore_1.getFeUserId)();
|
42
42
|
}, [data, loading]);
|
43
43
|
const handleH5EnterLink = (0, react_1.useCallback)(() => {
|
44
44
|
if (data.length <= 0) {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export declare const FAKE_USER_KEY = "SXP_FAKE_USER_ID";
|
2
|
+
export declare const FAKE_USER_STATE = "FAKE_USER_STATE";
|
2
3
|
export declare const storeAndLoadFeUserId: () => string;
|
3
4
|
export declare const removeFeUserId: () => void;
|
4
5
|
export declare const getFeUserId: () => boolean;
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getFeUserId = exports.removeFeUserId = exports.storeAndLoadFeUserId = exports.FAKE_USER_KEY = void 0;
|
3
|
+
exports.getFeUserId = exports.removeFeUserId = exports.storeAndLoadFeUserId = exports.FAKE_USER_STATE = exports.FAKE_USER_KEY = void 0;
|
4
4
|
const lodash_1 = require("lodash");
|
5
5
|
const tool_1 = require("./tool");
|
6
6
|
exports.FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
|
7
|
+
exports.FAKE_USER_STATE = 'FAKE_USER_STATE';
|
7
8
|
const storeAndLoadFeUserId = () => {
|
8
9
|
let fakeUserId = window.localStorage.getItem(exports.FAKE_USER_KEY);
|
9
10
|
if ((0, lodash_1.isEmpty)(fakeUserId)) {
|
@@ -18,7 +19,10 @@ const removeFeUserId = () => {
|
|
18
19
|
};
|
19
20
|
exports.removeFeUserId = removeFeUserId;
|
20
21
|
const getFeUserId = () => {
|
21
|
-
const
|
22
|
-
|
22
|
+
const fakeUserState = window.localStorage.getItem(exports.FAKE_USER_STATE);
|
23
|
+
if ((0, lodash_1.isEmpty)(fakeUserState)) {
|
24
|
+
window.localStorage.setItem(exports.FAKE_USER_STATE, 'true');
|
25
|
+
}
|
26
|
+
return (0, lodash_1.isEmpty)(fakeUserState);
|
23
27
|
};
|
24
28
|
exports.getFeUserId = getFeUserId;
|