pb-sxp-ui 1.13.0 → 1.13.2

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