pb-sxp-ui 1.11.0 → 1.11.1

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.js CHANGED
@@ -651,7 +651,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
651
651
  const themeTag = useRef();
652
652
  const curTime = useRef();
653
653
  const multiPostTimeRef = useRef();
654
- const sessionTimeRef = useRef();
655
654
  const [selectTag, setSelectTag] = useState(DEFAULT_TAG);
656
655
  const checkCommodityIndexRef = useRef(-1);
657
656
  const popupCurTimeRef = useRef(null);
@@ -833,20 +832,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
833
832
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
834
833
  return data;
835
834
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
836
- const refreshFeSession = useCallback(() => {
837
- var _a, _b, _c, _d, _e, _f;
835
+ const refreshFeSession = useCallback((enableReSid) => {
836
+ var _a, _b, _c, _d, _e;
838
837
  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;
839
838
  if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
840
- if (Math.floor((new Date() - ((_d = sessionTimeRef.current) !== null && _d !== void 0 ? _d : new Date())) / (1000 * 60)) >=
841
- ((_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)) {
839
+ const sessionStartTime = localStorage.getItem('sessionStartTime');
840
+ const sst = sessionStartTime ? new Date(sessionStartTime) : new Date();
841
+ if (Math.floor((new Date() - sst) / (1000 * 60)) >=
842
+ ((_e = (_d = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _d === void 0 ? void 0 : _d.expires) !== null && _e !== void 0 ? _e : 30)) {
842
843
  refreshFeSessionId();
844
+ curTime.current = new Date();
843
845
  }
846
+ localStorage.setItem('sessionStartTime', new Date().toISOString());
844
847
  }
845
- else {
848
+ else if (enableReSid) {
846
849
  refreshFeSessionId();
847
850
  }
848
- sessionTimeRef.current = new Date();
849
- }, [data, sessionTimeRef]);
851
+ }, [data]);
850
852
  const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
851
853
  // 关闭 BFF 事件上报
852
854
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
@@ -1010,7 +1012,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1010
1012
  });
1011
1013
  }, [bffEventReport, isFromHashtag]);
1012
1014
  const h5EnterLink = useCallback(() => {
1013
- var _a, _b;
1015
+ var _a, _b, _c, _d, _e;
1014
1016
  const queryString = location.search.slice(1);
1015
1017
  const params = qs.parse(queryString.replace(/\+/g, '%2B'));
1016
1018
  for (const key in params) {
@@ -1018,7 +1020,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1018
1020
  }
1019
1021
  const getVal = (key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ''; };
1020
1022
  const time = new Date();
1021
- curTime.current = time;
1023
+ 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;
1024
+ if (!((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) || !(curTime === null || curTime === void 0 ? void 0 : curTime.current)) {
1025
+ curTime.current = time;
1026
+ }
1022
1027
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
1023
1028
  eventInfo: {
1024
1029
  eventSubject: 'h5LinkEnterFeed',
@@ -1030,16 +1035,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1030
1035
  utmContent: getVal('utm_content'),
1031
1036
  enterTime: Math.floor(time / 1000) + '',
1032
1037
  requestId: null,
1033
- enterUrl: (_b = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : '',
1038
+ enterUrl: (_e = (_d = window === null || window === void 0 ? void 0 : window.location) === null || _d === void 0 ? void 0 : _d.href) !== null && _e !== void 0 ? _e : '',
1034
1039
  clSource: getVal('cl_source')
1035
1040
  },
1036
1041
  reportLayId: false
1037
1042
  });
1038
- }, [bffEventReport]);
1043
+ }, [bffEventReport, data, curTime]);
1039
1044
  useEffect(() => {
1040
1045
  if (!isShowConsent)
1041
1046
  h5EnterLink();
1042
- }, [isShowConsent]);
1047
+ }, [isShowConsent, h5EnterLink]);
1043
1048
  useEffect(() => {
1044
1049
  if (isShowConsent || isPreview)
1045
1050
  return;
@@ -17979,7 +17984,7 @@ var NavBack$1 = memo(NavBack);
17979
17984
  * @Author: binruan@chatlabs.com
17980
17985
  * @Date: 2024-03-20 10:27:31
17981
17986
  * @LastEditors: binruan@chatlabs.com
17982
- * @LastEditTime: 2024-12-13 17:20:22
17987
+ * @LastEditTime: 2024-12-16 15:03:38
17983
17988
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
17984
17989
  *
17985
17990
  */
@@ -18004,7 +18009,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18004
18009
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
18005
18010
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
18006
18011
  useEffect(() => {
18007
- refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession();
18012
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(true);
18008
18013
  }, []);
18009
18014
  useEffect(() => {
18010
18015
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {