pb-sxp-ui 1.10.11 → 1.11.0

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/pb-ui.js CHANGED
@@ -497,17 +497,17 @@
497
497
  let result = getFeSessionId();
498
498
  if (!result) {
499
499
  result = generateFeSessionId();
500
- window.sessionStorage.setItem(feRealSessionIdKey, result);
500
+ window.localStorage.setItem(feRealSessionIdKey, result);
501
501
  }
502
502
  return result;
503
503
  };
504
504
  const refreshFeSessionId = () => {
505
505
  const result = generateFeSessionId();
506
- window.sessionStorage.setItem(feRealSessionIdKey, result);
506
+ window.localStorage.setItem(feRealSessionIdKey, result);
507
507
  };
508
508
  // 获取 sessionID
509
509
  const getFeSessionId = () => {
510
- return window.sessionStorage.getItem(feRealSessionIdKey);
510
+ return window.localStorage.getItem(feRealSessionIdKey);
511
511
  };
512
512
 
513
513
  const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
@@ -666,6 +666,7 @@
666
666
  const themeTag = React.useRef();
667
667
  const curTime = React.useRef();
668
668
  const multiPostTimeRef = React.useRef();
669
+ const sessionTimeRef = React.useRef();
669
670
  const [selectTag, setSelectTag] = React.useState(DEFAULT_TAG);
670
671
  const checkCommodityIndexRef = React.useRef(-1);
671
672
  const popupCurTimeRef = React.useRef(null);
@@ -847,6 +848,20 @@
847
848
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
848
849
  return data;
849
850
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
851
+ const refreshFeSession = React.useCallback(() => {
852
+ var _a, _b, _c, _d, _e, _f;
853
+ const defaultGlobalConfig = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf) === null || _b === void 0 ? void 0 : _b.globalConfig;
854
+ if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
855
+ if (Math.floor((new Date() - ((_d = sessionTimeRef.current) !== null && _d !== void 0 ? _d : new Date())) / (1000 * 60)) >=
856
+ ((_f = (_e = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _e === void 0 ? void 0 : _e.expires) !== null && _f !== void 0 ? _f : 30)) {
857
+ refreshFeSessionId();
858
+ }
859
+ }
860
+ else {
861
+ refreshFeSessionId();
862
+ }
863
+ sessionTimeRef.current = new Date();
864
+ }, [data, sessionTimeRef]);
850
865
  const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
851
866
  // 关闭 BFF 事件上报
852
867
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
@@ -859,6 +874,7 @@
859
874
  // tpChannelId: 'H5' // 后端处理
860
875
  };
861
876
  }
877
+ refreshFeSession();
862
878
  const sessionID = storeAndLoadFeSessionId();
863
879
  const ef = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, { playbookType }), (layoutVariantId && reportLayId && { layoutVariantId })), eventInfo), (getDevice$1() && { sxpDevice: getDevice$1() })), (getSystem() && { sxpSystem: getSystem() })), (getBrowserInfo() && { sxpBrowser: getBrowserInfo() })), ((eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) && channel && { position: Number(eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.position) + 1 + '' }));
864
880
  const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
@@ -874,7 +890,16 @@
874
890
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
875
891
  type: 'beacon'
876
892
  });
877
- }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
893
+ }, [
894
+ bffFetch,
895
+ curReqInfo,
896
+ enableReportEvent,
897
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
898
+ layoutVariantId,
899
+ globalConfig,
900
+ playbookType,
901
+ refreshFeSession
902
+ ]);
878
903
  const bffFbReport = React.useCallback(({ eventName, product }) => {
879
904
  var _a, _b, _c, _d, _e;
880
905
  if (!enableReportEvent ||
@@ -1173,7 +1198,8 @@
1173
1198
  channel,
1174
1199
  eventTimeList,
1175
1200
  setEventTimeList,
1176
- multiPostTimeRef
1201
+ multiPostTimeRef,
1202
+ refreshFeSession
1177
1203
  } }, isShowConsent ? (React.createElement(Consent$4, Object.assign({}, (_e = (_d = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.item) === null || _e === void 0 ? void 0 : _e.props))) : (render({
1178
1204
  rtcList,
1179
1205
  mutateLike: bffMutateLike,
@@ -9778,7 +9804,7 @@
9778
9804
  * @Author: binruan@chatlabs.com
9779
9805
  * @Date: 2023-11-02 18:34:34
9780
9806
  * @LastEditors: binruan@chatlabs.com
9781
- * @LastEditTime: 2024-11-20 18:37:10
9807
+ * @LastEditTime: 2024-12-12 16:35:54
9782
9808
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Modal\index.tsx
9783
9809
  *
9784
9810
  */
@@ -9836,7 +9862,7 @@
9836
9862
  }, [isOpen, popup]);
9837
9863
  const child = React.useCallback(() => {
9838
9864
  return children;
9839
- }, [_popup, openState, globalConfig]);
9865
+ }, [_popup, openState, globalConfig, schema]);
9840
9866
  React.useEffect(() => {
9841
9867
  const trapFocus = (element) => {
9842
9868
  var focusableEls = element === null || element === void 0 ? void 0 : element.querySelectorAll('[role="button"],a, a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
@@ -16602,13 +16628,13 @@ Made in Italy` })));
16602
16628
  * @Author: binruan@chatlabs.com
16603
16629
  * @Date: 2023-12-26 10:38:53
16604
16630
  * @LastEditors: binruan@chatlabs.com
16605
- * @LastEditTime: 2024-10-29 18:04:27
16631
+ * @LastEditTime: 2024-12-11 18:24:31
16606
16632
  * @FilePath: \pb-sxp-ui\src\core\context\EditorDataProvider.tsx
16607
16633
  *
16608
16634
  */
16609
16635
  const EditorDataContext = React.createContext({});
16610
16636
  const EditorDataProvider = ({ children, data }) => {
16611
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
16637
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
16612
16638
  const [openHashtag, setOpenHashtag] = React.useState(false);
16613
16639
  const [openConsent, setOpenConsent] = React.useState(false);
16614
16640
  const [consentPopupCate, setConsentPopupCate] = React.useState('');
@@ -16639,7 +16665,8 @@ Made in Italy` })));
16639
16665
  consentPopupCate,
16640
16666
  setConsentPopupCate,
16641
16667
  openMultiPosts,
16642
- setOpenMultiPosts
16668
+ setOpenMultiPosts,
16669
+ pageTypeList: (_p = data === null || data === void 0 ? void 0 : data.pageTypeList) !== null && _p !== void 0 ? _p : []
16643
16670
  } }, children));
16644
16671
  };
16645
16672
  function useEditorDataProvider() {
@@ -17963,6 +17990,14 @@ Made in Italy` })));
17963
17990
  };
17964
17991
  var NavBack$1 = React.memo(NavBack);
17965
17992
 
17993
+ /*
17994
+ * @Author: binruan@chatlabs.com
17995
+ * @Date: 2024-03-20 10:27:31
17996
+ * @LastEditors: binruan@chatlabs.com
17997
+ * @LastEditTime: 2024-12-13 17:20:22
17998
+ * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
17999
+ *
18000
+ */
17966
18001
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], licenseUrl }) => {
17967
18002
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
17968
18003
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -17978,13 +18013,13 @@ Made in Italy` })));
17978
18013
  const [isReload, setIsReload] = React.useState(new Date().getTime());
17979
18014
  const skipLinkRef = React.useRef(false);
17980
18015
  const [pageNum, setPageNum] = React.useState(2);
17981
- const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel } = useSxpDataSource();
18016
+ const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession } = useSxpDataSource();
17982
18017
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
17983
18018
  const isShowFingerTip = React.useMemo(() => {
17984
18019
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
17985
18020
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
17986
18021
  React.useEffect(() => {
17987
- refreshFeSessionId();
18022
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession();
17988
18023
  }, []);
17989
18024
  React.useEffect(() => {
17990
18025
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
@@ -17993,7 +18028,6 @@ Made in Italy` })));
17993
18028
  }
17994
18029
  }, [data === null || data === void 0 ? void 0 : data.length]);
17995
18030
  const handleH5EnterLink = React.useCallback(() => {
17996
- refreshFeSessionId();
17997
18031
  h5EnterLink === null || h5EnterLink === void 0 ? void 0 : h5EnterLink();
17998
18032
  if (data.length > 0) {
17999
18033
  const now = new Date();