pb-sxp-ui 1.13.3 → 1.13.5

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
@@ -677,12 +677,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
677
677
  const bffDataSource = React.useMemo(() => {
678
678
  return dataSources === null || dataSources === void 0 ? void 0 : dataSources.find((d) => d.type === DataSourceType.BFF);
679
679
  }, [dataSources]);
680
+ const fakeUserId = React.useMemo(() => {
681
+ var _a;
682
+ return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
683
+ }, [bffDataSource]);
680
684
  // bff API 请求方法
681
685
  const bffFetch = React.useCallback((path, options) => {
682
686
  if (!bffDataSource)
683
687
  return;
684
688
  const url = bffDataSource.url;
685
- const fakeUserId = storeAndLoadFeUserId();
686
689
  if (options === null || options === void 0 ? void 0 : options.query) {
687
690
  const queryString = qs.stringify(options.query);
688
691
  path = `${path}?${queryString}`;
@@ -690,19 +693,19 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
690
693
  // 事件上报优化
691
694
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
692
695
  if (options.type === 'beacon' && navigator.sendBeacon) {
693
- return navigator.sendBeacon(`${url}/api/v1${path}`, new Blob([
696
+ return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
694
697
  JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
695
698
  ], { type: 'application/json;charset=UTF-8' }));
696
699
  }
697
700
  return window
698
- .fetch(`${url}/api/v1${path}`, {
701
+ .fetch(`${url}/api/${path}`, {
699
702
  headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
700
703
  method: options.method,
701
704
  body: JSON.stringify(options.body)
702
705
  })
703
706
  .then((res) => res.json())
704
707
  .catch((err) => Promise.reject(err));
705
- }, [bffDataSource]);
708
+ }, [bffDataSource, fakeUserId]);
706
709
  // 获取推荐视频数据
707
710
  const getRecommendVideos = React.useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
708
711
  var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
@@ -740,7 +743,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
740
743
  const recurveRecList = (query) => __awaiter(void 0, void 0, void 0, function* () {
741
744
  var _v, _w, _x, _y, _z, _0;
742
745
  query.pageNum = pageNum;
743
- result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
746
+ result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
744
747
  if (!(result === null || result === void 0 ? void 0 : result.success)) {
745
748
  return undefined;
746
749
  }
@@ -762,7 +765,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
762
765
  if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
763
766
  query = Object.assign(Object.assign({}, query), { directPage: true, level: 1, pageNum: (_o = query === null || query === void 0 ? void 0 : query.pageNum) !== null && _o !== void 0 ? _o : 1 });
764
767
  }
765
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
768
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
766
769
  if (!(result === null || result === void 0 ? void 0 : result.success)) {
767
770
  return undefined;
768
771
  }
@@ -812,6 +815,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
812
815
  return expire;
813
816
  }, [data]);
814
817
  const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
818
+ var _a;
815
819
  // 关闭 BFF 事件上报
816
820
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
817
821
  return;
@@ -833,14 +837,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
833
837
  console.log('userInfo:', userInfo);
834
838
  console.log('eventInfo:', ef);
835
839
  console.log('========= 结束 =========');
836
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/event/report', {
840
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/CLD/${(_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']}/${eventInfo === null || eventInfo === void 0 ? void 0 : eventInfo.eventSubject}`, {
837
841
  method: 'POST',
838
842
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
839
843
  type: 'beacon'
840
844
  });
841
- }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
845
+ }, [
846
+ bffFetch,
847
+ curReqInfo,
848
+ enableReportEvent,
849
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
850
+ layoutVariantId,
851
+ globalConfig,
852
+ playbookType,
853
+ bffDataSource
854
+ ]);
842
855
  const bffFbReport = React.useCallback(({ eventName, product }) => {
843
- var _a, _b, _c, _d, _e;
856
+ var _a, _b, _c, _d, _e, _f;
844
857
  if (!enableReportEvent ||
845
858
  !enabledMetaConversionApi ||
846
859
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
@@ -852,7 +865,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
852
865
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
853
866
  const fix_par = {
854
867
  event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
855
- external_id: storeAndLoadFeUserId(),
868
+ external_id: fakeUserId,
856
869
  client_user_agent: (_e = (_d = window === null || window === void 0 ? void 0 : window.navigator) === null || _d === void 0 ? void 0 : _d.userAgent) !== null && _e !== void 0 ? _e : '',
857
870
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
858
871
  fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
@@ -904,22 +917,30 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
904
917
  }
905
918
  };
906
919
  getEventParams(jsonParams);
907
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
920
+ return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(`v2/event/report/FB/${(_f = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _f === void 0 ? void 0 : _f['x-app-id']}/${eventName}`, {
908
921
  method: 'POST',
909
922
  body: jsonParams,
910
923
  type: 'beacon'
911
924
  });
912
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, globalConfig]);
925
+ }, [
926
+ bffFetch,
927
+ enableReportEvent,
928
+ enabledMetaConversionApi,
929
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
930
+ globalConfig,
931
+ fakeUserId,
932
+ bffDataSource
933
+ ]);
913
934
  const bffMutateLike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
914
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/like', { method: 'POST', body }));
935
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
915
936
  return res === null || res === void 0 ? void 0 : res.success;
916
937
  }), [bffFetch]);
917
938
  const bffMutateUnlike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
918
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/unlike', { method: 'POST', body }));
939
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
919
940
  return res === null || res === void 0 ? void 0 : res.success;
920
941
  }), [bffFetch]);
921
942
  const bffSubmitForm = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
922
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/customform', { method: 'POST', body }));
943
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
923
944
  return res === null || res === void 0 ? void 0 : res.success;
924
945
  }), [bffFetch]);
925
946
  // 获取 Tag
@@ -934,7 +955,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
934
955
  const key = val.split('=')[0];
935
956
  return (_b = ((_a = utmParameter === null || utmParameter === void 0 ? void 0 : utmParameter.channels) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.includes(key);
936
957
  })) === null || _9 === void 0 ? void 0 : _9.join('&')) !== null && _10 !== void 0 ? _10 : '';
937
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
958
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
938
959
  setTagList((_12 = (_11 = result === null || result === void 0 ? void 0 : result.data) === null || _11 === void 0 ? void 0 : _11.tags) !== null && _12 !== void 0 ? _12 : []);
939
960
  }
940
961
  catch (e) {
@@ -1008,10 +1029,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
1008
1029
  let curData;
1009
1030
  let gldata;
1010
1031
  if (data === null || data === void 0 ? void 0 : data.layoutVariantId) {
1032
+ layId = data === null || data === void 0 ? void 0 : data.layoutVariantId;
1033
+ setLayoutVariantId(data === null || data === void 0 ? void 0 : data.layoutVariantId);
1011
1034
  const id = (_b = (_a = data === null || data === void 0 ? void 0 : data.layoutVariantId) === null || _a === void 0 ? void 0 : _a.split('-')) === null || _b === void 0 ? void 0 : _b[1];
1012
1035
  if (id) {
1013
- layId = id;
1014
- setLayoutVariantId(id);
1015
1036
  curData = dataList === null || dataList === void 0 ? void 0 : dataList.find((item) => (item === null || item === void 0 ? void 0 : item.id) === id);
1016
1037
  if (curData) {
1017
1038
  setPageData(curData);
@@ -10098,7 +10119,7 @@ var CommodityGroup$1 = React.memo(CommodityGroup);
10098
10119
  * @Author: binruan@chatlabs.com
10099
10120
  * @Date: 2024-03-20 14:56:16
10100
10121
  * @LastEditors: binruan@chatlabs.com
10101
- * @LastEditTime: 2024-10-24 17:51:19
10122
+ * @LastEditTime: 2024-12-20 14:32:26
10102
10123
  * @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
10103
10124
  *
10104
10125
  */
@@ -10136,14 +10157,16 @@ const getBgStyle = (imgSrc) => {
10136
10157
  };
10137
10158
  const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
10138
10159
  var _a, _b, _c, _d, _e, _f, _g, _h;
10160
+ let text = '';
10139
10161
  if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
10140
10162
  return null;
10141
- let price = (product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price) ? product === null || product === void 0 ? void 0 : product.price : 7000;
10142
- let text = '';
10163
+ let price = Number((product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price) ? product === null || product === void 0 ? void 0 : product.price : 7000);
10164
+ if (typeof price !== 'number')
10165
+ return text;
10143
10166
  let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
10144
10167
  let currency = (product === null || product === void 0 ? void 0 : product.currency) ? (_c = (_b = (_a = product === null || product === void 0 ? void 0 : product.currency) === null || _a === void 0 ? void 0 : _a.split('-')[1]) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== null && _c !== void 0 ? _c : '' : '$';
10145
10168
  const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
10146
- let decPic = price.toString();
10169
+ let decPic = price === null || price === void 0 ? void 0 : price.toString();
10147
10170
  if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
10148
10171
  decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
10149
10172
  }
@@ -17922,7 +17945,7 @@ var NavBack$1 = React.memo(NavBack);
17922
17945
  * @Author: binruan@chatlabs.com
17923
17946
  * @Date: 2024-03-20 10:27:31
17924
17947
  * @LastEditors: binruan@chatlabs.com
17925
- * @LastEditTime: 2024-12-18 10:24:20
17948
+ * @LastEditTime: 2025-01-03 17:10:56
17926
17949
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
17927
17950
  *
17928
17951
  */
@@ -18047,6 +18070,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
18047
18070
  skipLinkRef.current = false;
18048
18071
  }
18049
18072
  // 页面可见时触发,注意页面初始化时不会触发
18073
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false);
18050
18074
  handleH5EnterLink();
18051
18075
  if (repCond) {
18052
18076
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);