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/index.cjs CHANGED
@@ -504,17 +504,17 @@ const storeAndLoadFeSessionId = () => {
504
504
  let result = getFeSessionId();
505
505
  if (!result) {
506
506
  result = generateFeSessionId();
507
- window.sessionStorage.setItem(feRealSessionIdKey, result);
507
+ window.localStorage.setItem(feRealSessionIdKey, result);
508
508
  }
509
509
  return result;
510
510
  };
511
511
  const refreshFeSessionId = () => {
512
512
  const result = generateFeSessionId();
513
- window.sessionStorage.setItem(feRealSessionIdKey, result);
513
+ window.localStorage.setItem(feRealSessionIdKey, result);
514
514
  };
515
515
  // 获取 sessionID
516
516
  const getFeSessionId = () => {
517
- return window.sessionStorage.getItem(feRealSessionIdKey);
517
+ return window.localStorage.getItem(feRealSessionIdKey);
518
518
  };
519
519
 
520
520
  const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
@@ -673,6 +673,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
673
673
  const themeTag = React.useRef();
674
674
  const curTime = React.useRef();
675
675
  const multiPostTimeRef = React.useRef();
676
+ const sessionTimeRef = React.useRef();
676
677
  const [selectTag, setSelectTag] = React.useState(DEFAULT_TAG);
677
678
  const checkCommodityIndexRef = React.useRef(-1);
678
679
  const popupCurTimeRef = React.useRef(null);
@@ -854,6 +855,20 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
854
855
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
855
856
  return data;
856
857
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
858
+ const refreshFeSession = React.useCallback(() => {
859
+ var _a, _b, _c, _d, _e, _f;
860
+ 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;
861
+ if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
862
+ if (Math.floor((new Date() - ((_d = sessionTimeRef.current) !== null && _d !== void 0 ? _d : new Date())) / (1000 * 60)) >=
863
+ ((_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)) {
864
+ refreshFeSessionId();
865
+ }
866
+ }
867
+ else {
868
+ refreshFeSessionId();
869
+ }
870
+ sessionTimeRef.current = new Date();
871
+ }, [data, sessionTimeRef]);
857
872
  const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
858
873
  // 关闭 BFF 事件上报
859
874
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
@@ -866,6 +881,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
866
881
  // tpChannelId: 'H5' // 后端处理
867
882
  };
868
883
  }
884
+ refreshFeSession();
869
885
  const sessionID = storeAndLoadFeSessionId();
870
886
  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 + '' }));
871
887
  const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
@@ -881,7 +897,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
881
897
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
882
898
  type: 'beacon'
883
899
  });
884
- }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
900
+ }, [
901
+ bffFetch,
902
+ curReqInfo,
903
+ enableReportEvent,
904
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
905
+ layoutVariantId,
906
+ globalConfig,
907
+ playbookType,
908
+ refreshFeSession
909
+ ]);
885
910
  const bffFbReport = React.useCallback(({ eventName, product }) => {
886
911
  var _a, _b, _c, _d, _e;
887
912
  if (!enableReportEvent ||
@@ -1180,7 +1205,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1180
1205
  channel,
1181
1206
  eventTimeList,
1182
1207
  setEventTimeList,
1183
- multiPostTimeRef
1208
+ multiPostTimeRef,
1209
+ refreshFeSession
1184
1210
  } }, 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({
1185
1211
  rtcList,
1186
1212
  mutateLike: bffMutateLike,
@@ -9785,7 +9811,7 @@ SwiperSlide.displayName = 'SwiperSlide';
9785
9811
  * @Author: binruan@chatlabs.com
9786
9812
  * @Date: 2023-11-02 18:34:34
9787
9813
  * @LastEditors: binruan@chatlabs.com
9788
- * @LastEditTime: 2024-11-20 18:37:10
9814
+ * @LastEditTime: 2024-12-12 16:35:54
9789
9815
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Modal\index.tsx
9790
9816
  *
9791
9817
  */
@@ -9843,7 +9869,7 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
9843
9869
  }, [isOpen, popup]);
9844
9870
  const child = React.useCallback(() => {
9845
9871
  return children;
9846
- }, [_popup, openState, globalConfig]);
9872
+ }, [_popup, openState, globalConfig, schema]);
9847
9873
  React.useEffect(() => {
9848
9874
  const trapFocus = (element) => {
9849
9875
  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])');
@@ -16609,13 +16635,13 @@ var settingRender$1 = [
16609
16635
  * @Author: binruan@chatlabs.com
16610
16636
  * @Date: 2023-12-26 10:38:53
16611
16637
  * @LastEditors: binruan@chatlabs.com
16612
- * @LastEditTime: 2024-10-29 18:04:27
16638
+ * @LastEditTime: 2024-12-11 18:24:31
16613
16639
  * @FilePath: \pb-sxp-ui\src\core\context\EditorDataProvider.tsx
16614
16640
  *
16615
16641
  */
16616
16642
  const EditorDataContext = React.createContext({});
16617
16643
  const EditorDataProvider = ({ children, data }) => {
16618
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
16644
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
16619
16645
  const [openHashtag, setOpenHashtag] = React.useState(false);
16620
16646
  const [openConsent, setOpenConsent] = React.useState(false);
16621
16647
  const [consentPopupCate, setConsentPopupCate] = React.useState('');
@@ -16646,7 +16672,8 @@ const EditorDataProvider = ({ children, data }) => {
16646
16672
  consentPopupCate,
16647
16673
  setConsentPopupCate,
16648
16674
  openMultiPosts,
16649
- setOpenMultiPosts
16675
+ setOpenMultiPosts,
16676
+ pageTypeList: (_p = data === null || data === void 0 ? void 0 : data.pageTypeList) !== null && _p !== void 0 ? _p : []
16650
16677
  } }, children));
16651
16678
  };
16652
16679
  function useEditorDataProvider() {
@@ -17970,6 +17997,14 @@ const NavBack = ({ data, minusHeight, tagHeight, onClick }) => {
17970
17997
  };
17971
17998
  var NavBack$1 = React.memo(NavBack);
17972
17999
 
18000
+ /*
18001
+ * @Author: binruan@chatlabs.com
18002
+ * @Date: 2024-03-20 10:27:31
18003
+ * @LastEditors: binruan@chatlabs.com
18004
+ * @LastEditTime: 2024-12-13 17:20:22
18005
+ * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
18006
+ *
18007
+ */
17973
18008
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], licenseUrl }) => {
17974
18009
  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;
17975
18010
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -17985,13 +18020,13 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
17985
18020
  const [isReload, setIsReload] = React.useState(new Date().getTime());
17986
18021
  const skipLinkRef = React.useRef(false);
17987
18022
  const [pageNum, setPageNum] = React.useState(2);
17988
- 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();
18023
+ 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();
17989
18024
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
17990
18025
  const isShowFingerTip = React.useMemo(() => {
17991
18026
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
17992
18027
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
17993
18028
  React.useEffect(() => {
17994
- refreshFeSessionId();
18029
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession();
17995
18030
  }, []);
17996
18031
  React.useEffect(() => {
17997
18032
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
@@ -18000,7 +18035,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18000
18035
  }
18001
18036
  }, [data === null || data === void 0 ? void 0 : data.length]);
18002
18037
  const handleH5EnterLink = React.useCallback(() => {
18003
- refreshFeSessionId();
18004
18038
  h5EnterLink === null || h5EnterLink === void 0 ? void 0 : h5EnterLink();
18005
18039
  if (data.length > 0) {
18006
18040
  const now = new Date();