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/index.cjs +53 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -45
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +53 -45
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.js +1 -0
- package/es/core/context/SxpDataSourceProvider.js +39 -18
- package/es/core/utils/materials.js +5 -3
- package/es/materials/sxp/popup/Iframe/index.d.ts +0 -4
- package/es/materials/sxp/popup/Iframe/index.js +4 -5
- package/es/materials/sxp/popup/Iframe/settingRender.js +0 -15
- package/lib/core/components/SxpPageRender/index.js +1 -0
- package/lib/core/context/SxpDataSourceProvider.js +39 -18
- package/lib/core/utils/materials.js +5 -3
- package/lib/materials/sxp/popup/Iframe/index.d.ts +0 -4
- package/lib/materials/sxp/popup/Iframe/index.js +4 -5
- package/lib/materials/sxp/popup/Iframe/settingRender.js +0 -15
- package/package.json +1 -1
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
|
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
|
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(
|
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
|
-
}, [
|
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:
|
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(
|
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
|
-
}, [
|
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-
|
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
|
-
|
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
|
}
|
@@ -11961,7 +11984,7 @@ const CommodityList = createMaterial(CommodityListComponent, {
|
|
11961
11984
|
* @Author: binruan@chatlabs.com
|
11962
11985
|
* @Date: 2023-10-27 14:06:35
|
11963
11986
|
* @LastEditors: binruan@chatlabs.com
|
11964
|
-
* @LastEditTime: 2024-
|
11987
|
+
* @LastEditTime: 2024-08-08 17:32:11
|
11965
11988
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
|
11966
11989
|
*
|
11967
11990
|
*/
|
@@ -11975,32 +11998,16 @@ var settingRender$8 = [
|
|
11975
11998
|
name: ['style', 'backgroundColor']
|
11976
11999
|
}
|
11977
12000
|
]
|
11978
|
-
},
|
11979
|
-
{
|
11980
|
-
title: 'iframe',
|
11981
|
-
child: [
|
11982
|
-
{
|
11983
|
-
type: 'TextArea',
|
11984
|
-
label: 'url',
|
11985
|
-
name: ['props', 'iframe', 'src']
|
11986
|
-
},
|
11987
|
-
{
|
11988
|
-
type: 'TextArea',
|
11989
|
-
label: 'allow',
|
11990
|
-
name: ['props', 'iframe', 'allow']
|
11991
|
-
}
|
11992
|
-
]
|
11993
12001
|
}
|
11994
12002
|
];
|
11995
12003
|
|
11996
12004
|
const Iframe$1 = (_a) => {
|
11997
12005
|
var _b, _c;
|
11998
|
-
var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel
|
12006
|
+
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"]);
|
11999
12007
|
const { popupDetailData } = useSxpDataSource();
|
12000
|
-
const
|
12001
|
-
|
12002
|
-
|
12003
|
-
React.createElement("iframe", { src: iframeUrl, allow: allow, scrolling: 'no', style: {
|
12008
|
+
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;
|
12009
|
+
return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign({}, style))}` }, props),
|
12010
|
+
React.createElement("iframe", { src: iframeUrl, style: {
|
12004
12011
|
width: '100%',
|
12005
12012
|
height: 'calc(100% - 50px)',
|
12006
12013
|
marginTop: '50px',
|
@@ -17938,7 +17945,7 @@ var NavBack$1 = React.memo(NavBack);
|
|
17938
17945
|
* @Author: binruan@chatlabs.com
|
17939
17946
|
* @Date: 2024-03-20 10:27:31
|
17940
17947
|
* @LastEditors: binruan@chatlabs.com
|
17941
|
-
* @LastEditTime: 2024-12-
|
17948
|
+
* @LastEditTime: 2024-12-26 17:33:54
|
17942
17949
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
17943
17950
|
*
|
17944
17951
|
*/
|
@@ -18063,6 +18070,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
18063
18070
|
skipLinkRef.current = false;
|
18064
18071
|
}
|
18065
18072
|
// 页面可见时触发,注意页面初始化时不会触发
|
18073
|
+
refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
|
18066
18074
|
handleH5EnterLink();
|
18067
18075
|
if (repCond) {
|
18068
18076
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|
@@ -18905,7 +18913,7 @@ var index$1 = React.memo(DiyPortalPreview);
|
|
18905
18913
|
* @Author: binruan@chatlabs.com
|
18906
18914
|
* @Date: 2023-10-31 10:56:01
|
18907
18915
|
* @LastEditors: binruan@chatlabs.com
|
18908
|
-
* @LastEditTime: 2024-
|
18916
|
+
* @LastEditTime: 2024-10-23 15:07:29
|
18909
18917
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Popup\index.tsx
|
18910
18918
|
*
|
18911
18919
|
*/
|