pb-sxp-ui 1.13.2 → 1.13.4

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
@@ -670,12 +670,15 @@
670
670
  const bffDataSource = React.useMemo(() => {
671
671
  return dataSources === null || dataSources === void 0 ? void 0 : dataSources.find((d) => d.type === DataSourceType.BFF);
672
672
  }, [dataSources]);
673
+ const fakeUserId = React.useMemo(() => {
674
+ var _a;
675
+ return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
676
+ }, [bffDataSource]);
673
677
  // bff API 请求方法
674
678
  const bffFetch = React.useCallback((path, options) => {
675
679
  if (!bffDataSource)
676
680
  return;
677
681
  const url = bffDataSource.url;
678
- const fakeUserId = storeAndLoadFeUserId();
679
682
  if (options === null || options === void 0 ? void 0 : options.query) {
680
683
  const queryString = qs.stringify(options.query);
681
684
  path = `${path}?${queryString}`;
@@ -683,19 +686,19 @@
683
686
  // 事件上报优化
684
687
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
685
688
  if (options.type === 'beacon' && navigator.sendBeacon) {
686
- return navigator.sendBeacon(`${url}/api/v1${path}`, new Blob([
689
+ return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
687
690
  JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
688
691
  ], { type: 'application/json;charset=UTF-8' }));
689
692
  }
690
693
  return window
691
- .fetch(`${url}/api/v1${path}`, {
694
+ .fetch(`${url}/api/${path}`, {
692
695
  headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
693
696
  method: options.method,
694
697
  body: JSON.stringify(options.body)
695
698
  })
696
699
  .then((res) => res.json())
697
700
  .catch((err) => Promise.reject(err));
698
- }, [bffDataSource]);
701
+ }, [bffDataSource, fakeUserId]);
699
702
  // 获取推荐视频数据
700
703
  const getRecommendVideos = React.useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
701
704
  var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
@@ -733,7 +736,7 @@
733
736
  const recurveRecList = (query) => __awaiter(void 0, void 0, void 0, function* () {
734
737
  var _v, _w, _x, _y, _z, _0;
735
738
  query.pageNum = pageNum;
736
- result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
739
+ result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
737
740
  if (!(result === null || result === void 0 ? void 0 : result.success)) {
738
741
  return undefined;
739
742
  }
@@ -755,7 +758,7 @@
755
758
  if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
756
759
  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 });
757
760
  }
758
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
761
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
759
762
  if (!(result === null || result === void 0 ? void 0 : result.success)) {
760
763
  return undefined;
761
764
  }
@@ -805,6 +808,7 @@
805
808
  return expire;
806
809
  }, [data]);
807
810
  const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
811
+ var _a;
808
812
  // 关闭 BFF 事件上报
809
813
  if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
810
814
  return;
@@ -826,14 +830,23 @@
826
830
  console.log('userInfo:', userInfo);
827
831
  console.log('eventInfo:', ef);
828
832
  console.log('========= 结束 =========');
829
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/event/report', {
833
+ 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}`, {
830
834
  method: 'POST',
831
835
  body: { userInfo: realUserInfo, eventInfo: realEventInfo },
832
836
  type: 'beacon'
833
837
  });
834
- }, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
838
+ }, [
839
+ bffFetch,
840
+ curReqInfo,
841
+ enableReportEvent,
842
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
843
+ layoutVariantId,
844
+ globalConfig,
845
+ playbookType,
846
+ bffDataSource
847
+ ]);
835
848
  const bffFbReport = React.useCallback(({ eventName, product }) => {
836
- var _a, _b, _c, _d, _e;
849
+ var _a, _b, _c, _d, _e, _f;
837
850
  if (!enableReportEvent ||
838
851
  !enabledMetaConversionApi ||
839
852
  (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
@@ -845,7 +858,7 @@
845
858
  const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
846
859
  const fix_par = {
847
860
  event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
848
- external_id: storeAndLoadFeUserId(),
861
+ external_id: fakeUserId,
849
862
  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 : '',
850
863
  fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
851
864
  fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
@@ -897,22 +910,30 @@
897
910
  }
898
911
  };
899
912
  getEventParams(jsonParams);
900
- return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
913
+ 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}`, {
901
914
  method: 'POST',
902
915
  body: jsonParams,
903
916
  type: 'beacon'
904
917
  });
905
- }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, globalConfig]);
918
+ }, [
919
+ bffFetch,
920
+ enableReportEvent,
921
+ enabledMetaConversionApi,
922
+ globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
923
+ globalConfig,
924
+ fakeUserId,
925
+ bffDataSource
926
+ ]);
906
927
  const bffMutateLike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
907
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/like', { method: 'POST', body }));
928
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
908
929
  return res === null || res === void 0 ? void 0 : res.success;
909
930
  }), [bffFetch]);
910
931
  const bffMutateUnlike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
911
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/unlike', { method: 'POST', body }));
932
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
912
933
  return res === null || res === void 0 ? void 0 : res.success;
913
934
  }), [bffFetch]);
914
935
  const bffSubmitForm = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
915
- const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/customform', { method: 'POST', body }));
936
+ const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
916
937
  return res === null || res === void 0 ? void 0 : res.success;
917
938
  }), [bffFetch]);
918
939
  // 获取 Tag
@@ -927,7 +948,7 @@
927
948
  const key = val.split('=')[0];
928
949
  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);
929
950
  })) === null || _9 === void 0 ? void 0 : _9.join('&')) !== null && _10 !== void 0 ? _10 : '';
930
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
951
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
931
952
  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 : []);
932
953
  }
933
954
  catch (e) {
@@ -1001,10 +1022,10 @@
1001
1022
  let curData;
1002
1023
  let gldata;
1003
1024
  if (data === null || data === void 0 ? void 0 : data.layoutVariantId) {
1025
+ layId = data === null || data === void 0 ? void 0 : data.layoutVariantId;
1026
+ setLayoutVariantId(data === null || data === void 0 ? void 0 : data.layoutVariantId);
1004
1027
  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];
1005
1028
  if (id) {
1006
- layId = id;
1007
- setLayoutVariantId(id);
1008
1029
  curData = dataList === null || dataList === void 0 ? void 0 : dataList.find((item) => (item === null || item === void 0 ? void 0 : item.id) === id);
1009
1030
  if (curData) {
1010
1031
  setPageData(curData);
@@ -10091,7 +10112,7 @@
10091
10112
  * @Author: binruan@chatlabs.com
10092
10113
  * @Date: 2024-03-20 14:56:16
10093
10114
  * @LastEditors: binruan@chatlabs.com
10094
- * @LastEditTime: 2024-10-24 17:51:19
10115
+ * @LastEditTime: 2024-12-20 14:32:26
10095
10116
  * @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
10096
10117
  *
10097
10118
  */
@@ -10129,14 +10150,16 @@
10129
10150
  };
10130
10151
  const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
10131
10152
  var _a, _b, _c, _d, _e, _f, _g, _h;
10153
+ let text = '';
10132
10154
  if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
10133
10155
  return null;
10134
- 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;
10135
- let text = '';
10156
+ 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);
10157
+ if (typeof price !== 'number')
10158
+ return text;
10136
10159
  let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
10137
10160
  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 : '' : '$';
10138
10161
  const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
10139
- let decPic = price.toString();
10162
+ let decPic = price === null || price === void 0 ? void 0 : price.toString();
10140
10163
  if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
10141
10164
  decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
10142
10165
  }
@@ -11954,7 +11977,7 @@ Made in Italy` })));
11954
11977
  * @Author: binruan@chatlabs.com
11955
11978
  * @Date: 2023-10-27 14:06:35
11956
11979
  * @LastEditors: binruan@chatlabs.com
11957
- * @LastEditTime: 2024-12-12 15:12:57
11980
+ * @LastEditTime: 2024-08-08 17:32:11
11958
11981
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
11959
11982
  *
11960
11983
  */
@@ -11968,32 +11991,16 @@ Made in Italy` })));
11968
11991
  name: ['style', 'backgroundColor']
11969
11992
  }
11970
11993
  ]
11971
- },
11972
- {
11973
- title: 'iframe',
11974
- child: [
11975
- {
11976
- type: 'TextArea',
11977
- label: 'url',
11978
- name: ['props', 'iframe', 'src']
11979
- },
11980
- {
11981
- type: 'TextArea',
11982
- label: 'allow',
11983
- name: ['props', 'iframe', 'allow']
11984
- }
11985
- ]
11986
11994
  }
11987
11995
  ];
11988
11996
 
11989
11997
  const Iframe$1 = (_a) => {
11990
11998
  var _b, _c;
11991
- var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel, iframe } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle", "isTel", "iframe"]);
11999
+ var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle", "isTel"]);
11992
12000
  const { popupDetailData } = useSxpDataSource();
11993
- const { src, allow } = iframe || {};
11994
- const iframeUrl = src || ((_c = (_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.video) === null || _b === void 0 ? void 0 : _b.bindCta) === null || _c === void 0 ? void 0 : _c.remark);
11995
- return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign(Object.assign({}, style), { overflow: 'hidden' }))}` }, props),
11996
- React.createElement("iframe", { src: iframeUrl, allow: allow, scrolling: 'no', style: {
12001
+ const iframeUrl = (_c = (_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.video) === null || _b === void 0 ? void 0 : _b.bindCta) === null || _c === void 0 ? void 0 : _c.remark;
12002
+ return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign({}, style))}` }, props),
12003
+ React.createElement("iframe", { src: iframeUrl, style: {
11997
12004
  width: '100%',
11998
12005
  height: 'calc(100% - 50px)',
11999
12006
  marginTop: '50px',
@@ -17931,7 +17938,7 @@ Made in Italy` })));
17931
17938
  * @Author: binruan@chatlabs.com
17932
17939
  * @Date: 2024-03-20 10:27:31
17933
17940
  * @LastEditors: binruan@chatlabs.com
17934
- * @LastEditTime: 2024-12-18 10:24:20
17941
+ * @LastEditTime: 2024-12-26 17:33:54
17935
17942
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
17936
17943
  *
17937
17944
  */
@@ -18056,6 +18063,7 @@ Made in Italy` })));
18056
18063
  skipLinkRef.current = false;
18057
18064
  }
18058
18065
  // 页面可见时触发,注意页面初始化时不会触发
18066
+ refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
18059
18067
  handleH5EnterLink();
18060
18068
  if (repCond) {
18061
18069
  SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
@@ -18898,7 +18906,7 @@ Made in Italy` })));
18898
18906
  * @Author: binruan@chatlabs.com
18899
18907
  * @Date: 2023-10-31 10:56:01
18900
18908
  * @LastEditors: binruan@chatlabs.com
18901
- * @LastEditTime: 2024-12-12 14:48:31
18909
+ * @LastEditTime: 2024-10-23 15:07:29
18902
18910
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Popup\index.tsx
18903
18911
  *
18904
18912
  */