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.
@@ -46,7 +46,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
46
46
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
47
47
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
48
48
  useEffect(() => {
49
- refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession();
49
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(true);
50
50
  }, []);
51
51
  useEffect(() => {
52
52
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
@@ -89,7 +89,7 @@ export interface ISxpDataSourceContext {
89
89
  eventTimeList?: Array<IEventTimeType>;
90
90
  setEventTimeList?: React.Dispatch<React.SetStateAction<Array<IEventTimeType>>>;
91
91
  multiPostTimeRef?: any;
92
- refreshFeSession?: () => void;
92
+ refreshFeSession?: (enableReSid?: boolean) => void;
93
93
  }
94
94
  export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
95
95
  export interface SxpDataSourceProviderProps {
@@ -36,7 +36,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
36
36
  const themeTag = useRef();
37
37
  const curTime = useRef();
38
38
  const multiPostTimeRef = useRef();
39
- const sessionTimeRef = useRef();
40
39
  const [selectTag, setSelectTag] = useState(DEFAULT_TAG);
41
40
  const checkCommodityIndexRef = useRef(-1);
42
41
  const popupCurTimeRef = useRef(null);
@@ -209,20 +208,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
209
208
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
210
209
  return data;
211
210
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
212
- const refreshFeSession = useCallback(() => {
213
- var _a, _b, _c, _d, _e, _f;
211
+ const refreshFeSession = useCallback((enableReSid) => {
212
+ var _a, _b, _c, _d, _e;
214
213
  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;
215
214
  if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
216
- if (Math.floor((new Date() - ((_d = sessionTimeRef.current) !== null && _d !== void 0 ? _d : new Date())) / (1000 * 60)) >=
217
- ((_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)) {
215
+ const sessionStartTime = localStorage.getItem('sessionStartTime');
216
+ const sst = sessionStartTime ? new Date(sessionStartTime) : new Date();
217
+ if (Math.floor((new Date() - sst) / (1000 * 60)) >=
218
+ ((_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)) {
218
219
  refreshFeSessionId();
220
+ curTime.current = new Date();
219
221
  }
222
+ localStorage.setItem('sessionStartTime', new Date().toISOString());
220
223
  }
221
- else {
224
+ else if (enableReSid) {
222
225
  refreshFeSessionId();
223
226
  }
224
- sessionTimeRef.current = new Date();
225
- }, [data, sessionTimeRef]);
227
+ }, [data]);
226
228
  const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
227
229
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
228
230
  return;
@@ -380,7 +382,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
380
382
  });
381
383
  }, [bffEventReport, isFromHashtag]);
382
384
  const h5EnterLink = useCallback(() => {
383
- var _a, _b;
385
+ var _a, _b, _c, _d, _e;
384
386
  const queryString = location.search.slice(1);
385
387
  const params = qs.parse(queryString.replace(/\+/g, '%2B'));
386
388
  for (const key in params) {
@@ -388,7 +390,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
388
390
  }
389
391
  const getVal = (key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ''; };
390
392
  const time = new Date();
391
- curTime.current = time;
393
+ 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;
394
+ 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)) {
395
+ curTime.current = time;
396
+ }
392
397
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
393
398
  eventInfo: {
394
399
  eventSubject: 'h5LinkEnterFeed',
@@ -400,16 +405,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
400
405
  utmContent: getVal('utm_content'),
401
406
  enterTime: Math.floor(time / 1000) + '',
402
407
  requestId: null,
403
- 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 : '',
408
+ 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 : '',
404
409
  clSource: getVal('cl_source')
405
410
  },
406
411
  reportLayId: false
407
412
  });
408
- }, [bffEventReport]);
413
+ }, [bffEventReport, data, curTime]);
409
414
  useEffect(() => {
410
415
  if (!isShowConsent)
411
416
  h5EnterLink();
412
- }, [isShowConsent]);
417
+ }, [isShowConsent, h5EnterLink]);
413
418
  useEffect(() => {
414
419
  if (isShowConsent || isPreview)
415
420
  return;
@@ -49,7 +49,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
49
49
  return data.length > 0 && !loading && ((0, localStore_1.getFeUserState)() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
50
50
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
51
51
  (0, react_1.useEffect)(() => {
52
- refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession();
52
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(true);
53
53
  }, []);
54
54
  (0, react_1.useEffect)(() => {
55
55
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
@@ -89,7 +89,7 @@ export interface ISxpDataSourceContext {
89
89
  eventTimeList?: Array<IEventTimeType>;
90
90
  setEventTimeList?: React.Dispatch<React.SetStateAction<Array<IEventTimeType>>>;
91
91
  multiPostTimeRef?: any;
92
- refreshFeSession?: () => void;
92
+ refreshFeSession?: (enableReSid?: boolean) => void;
93
93
  }
94
94
  export declare const SxpDataSourceContext: React.Context<ISxpDataSourceContext>;
95
95
  export interface SxpDataSourceProviderProps {
@@ -39,7 +39,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
39
39
  const themeTag = (0, react_1.useRef)();
40
40
  const curTime = (0, react_1.useRef)();
41
41
  const multiPostTimeRef = (0, react_1.useRef)();
42
- const sessionTimeRef = (0, react_1.useRef)();
43
42
  const [selectTag, setSelectTag] = (0, react_1.useState)(exports.DEFAULT_TAG);
44
43
  const checkCommodityIndexRef = (0, react_1.useRef)(-1);
45
44
  const popupCurTimeRef = (0, react_1.useRef)(null);
@@ -212,20 +211,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
212
211
  setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
213
212
  return data;
214
213
  }), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
215
- const refreshFeSession = (0, react_1.useCallback)(() => {
216
- var _a, _b, _c, _d, _e, _f;
214
+ const refreshFeSession = (0, react_1.useCallback)((enableReSid) => {
215
+ var _a, _b, _c, _d, _e;
217
216
  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;
218
217
  if ((_c = defaultGlobalConfig === null || defaultGlobalConfig === void 0 ? void 0 : defaultGlobalConfig.session) === null || _c === void 0 ? void 0 : _c.enable) {
219
- if (Math.floor((new Date() - ((_d = sessionTimeRef.current) !== null && _d !== void 0 ? _d : new Date())) / (1000 * 60)) >=
220
- ((_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)) {
218
+ const sessionStartTime = localStorage.getItem('sessionStartTime');
219
+ const sst = sessionStartTime ? new Date(sessionStartTime) : new Date();
220
+ if (Math.floor((new Date() - sst) / (1000 * 60)) >=
221
+ ((_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)) {
221
222
  (0, sessionStore_1.refreshFeSessionId)();
223
+ curTime.current = new Date();
222
224
  }
225
+ localStorage.setItem('sessionStartTime', new Date().toISOString());
223
226
  }
224
- else {
227
+ else if (enableReSid) {
225
228
  (0, sessionStore_1.refreshFeSessionId)();
226
229
  }
227
- sessionTimeRef.current = new Date();
228
- }, [data, sessionTimeRef]);
230
+ }, [data]);
229
231
  const bffEventReport = (0, react_1.useCallback)(({ userInfo, eventInfo, reportLayId = true }) => {
230
232
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
231
233
  return;
@@ -383,7 +385,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
383
385
  });
384
386
  }, [bffEventReport, isFromHashtag]);
385
387
  const h5EnterLink = (0, react_1.useCallback)(() => {
386
- var _a, _b;
388
+ var _a, _b, _c, _d, _e;
387
389
  const queryString = location.search.slice(1);
388
390
  const params = qs_1.default.parse(queryString.replace(/\+/g, '%2B'));
389
391
  for (const key in params) {
@@ -391,7 +393,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
391
393
  }
392
394
  const getVal = (key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ''; };
393
395
  const time = new Date();
394
- curTime.current = time;
396
+ 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;
397
+ 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)) {
398
+ curTime.current = time;
399
+ }
395
400
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
396
401
  eventInfo: {
397
402
  eventSubject: 'h5LinkEnterFeed',
@@ -403,16 +408,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
403
408
  utmContent: getVal('utm_content'),
404
409
  enterTime: Math.floor(time / 1000) + '',
405
410
  requestId: null,
406
- 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 : '',
411
+ 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 : '',
407
412
  clSource: getVal('cl_source')
408
413
  },
409
414
  reportLayId: false
410
415
  });
411
- }, [bffEventReport]);
416
+ }, [bffEventReport, data, curTime]);
412
417
  (0, react_1.useEffect)(() => {
413
418
  if (!isShowConsent)
414
419
  h5EnterLink();
415
- }, [isShowConsent]);
420
+ }, [isShowConsent, h5EnterLink]);
416
421
  (0, react_1.useEffect)(() => {
417
422
  if (isShowConsent || isPreview)
418
423
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",