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.js
CHANGED
@@ -655,12 +655,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
655
655
|
const bffDataSource = useMemo(() => {
|
656
656
|
return dataSources === null || dataSources === void 0 ? void 0 : dataSources.find((d) => d.type === DataSourceType.BFF);
|
657
657
|
}, [dataSources]);
|
658
|
+
const fakeUserId = useMemo(() => {
|
659
|
+
var _a;
|
660
|
+
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
|
661
|
+
}, [bffDataSource]);
|
658
662
|
// bff API 请求方法
|
659
663
|
const bffFetch = useCallback((path, options) => {
|
660
664
|
if (!bffDataSource)
|
661
665
|
return;
|
662
666
|
const url = bffDataSource.url;
|
663
|
-
const fakeUserId = storeAndLoadFeUserId();
|
664
667
|
if (options === null || options === void 0 ? void 0 : options.query) {
|
665
668
|
const queryString = qs.stringify(options.query);
|
666
669
|
path = `${path}?${queryString}`;
|
@@ -668,19 +671,19 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
668
671
|
// 事件上报优化
|
669
672
|
// Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
|
670
673
|
if (options.type === 'beacon' && navigator.sendBeacon) {
|
671
|
-
return navigator.sendBeacon(`${url}/api
|
674
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
672
675
|
JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
|
673
676
|
], { type: 'application/json;charset=UTF-8' }));
|
674
677
|
}
|
675
678
|
return window
|
676
|
-
.fetch(`${url}/api
|
679
|
+
.fetch(`${url}/api/${path}`, {
|
677
680
|
headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
|
678
681
|
method: options.method,
|
679
682
|
body: JSON.stringify(options.body)
|
680
683
|
})
|
681
684
|
.then((res) => res.json())
|
682
685
|
.catch((err) => Promise.reject(err));
|
683
|
-
}, [bffDataSource]);
|
686
|
+
}, [bffDataSource, fakeUserId]);
|
684
687
|
// 获取推荐视频数据
|
685
688
|
const getRecommendVideos = useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
|
686
689
|
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
@@ -718,7 +721,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
718
721
|
const recurveRecList = (query) => __awaiter(void 0, void 0, void 0, function* () {
|
719
722
|
var _v, _w, _x, _y, _z, _0;
|
720
723
|
query.pageNum = pageNum;
|
721
|
-
result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
|
724
|
+
result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/list', { method: 'POST', body: query }));
|
722
725
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
723
726
|
return undefined;
|
724
727
|
}
|
@@ -740,7 +743,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
740
743
|
if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
|
741
744
|
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 });
|
742
745
|
}
|
743
|
-
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
|
746
|
+
const 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
|
}
|
@@ -790,6 +793,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
790
793
|
return expire;
|
791
794
|
}, [data]);
|
792
795
|
const bffEventReport = useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
|
796
|
+
var _a;
|
793
797
|
// 关闭 BFF 事件上报
|
794
798
|
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
795
799
|
return;
|
@@ -811,14 +815,23 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
811
815
|
console.log('userInfo:', userInfo);
|
812
816
|
console.log('eventInfo:', ef);
|
813
817
|
console.log('========= 结束 =========');
|
814
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(
|
818
|
+
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}`, {
|
815
819
|
method: 'POST',
|
816
820
|
body: { userInfo: realUserInfo, eventInfo: realEventInfo },
|
817
821
|
type: 'beacon'
|
818
822
|
});
|
819
|
-
}, [
|
823
|
+
}, [
|
824
|
+
bffFetch,
|
825
|
+
curReqInfo,
|
826
|
+
enableReportEvent,
|
827
|
+
globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
|
828
|
+
layoutVariantId,
|
829
|
+
globalConfig,
|
830
|
+
playbookType,
|
831
|
+
bffDataSource
|
832
|
+
]);
|
820
833
|
const bffFbReport = useCallback(({ eventName, product }) => {
|
821
|
-
var _a, _b, _c, _d, _e;
|
834
|
+
var _a, _b, _c, _d, _e, _f;
|
822
835
|
if (!enableReportEvent ||
|
823
836
|
!enabledMetaConversionApi ||
|
824
837
|
(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
|
@@ -830,7 +843,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
830
843
|
const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
|
831
844
|
const fix_par = {
|
832
845
|
event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
|
833
|
-
external_id:
|
846
|
+
external_id: fakeUserId,
|
834
847
|
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 : '',
|
835
848
|
fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
|
836
849
|
fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
|
@@ -882,22 +895,30 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
882
895
|
}
|
883
896
|
};
|
884
897
|
getEventParams(jsonParams);
|
885
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(
|
898
|
+
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}`, {
|
886
899
|
method: 'POST',
|
887
900
|
body: jsonParams,
|
888
901
|
type: 'beacon'
|
889
902
|
});
|
890
|
-
}, [
|
903
|
+
}, [
|
904
|
+
bffFetch,
|
905
|
+
enableReportEvent,
|
906
|
+
enabledMetaConversionApi,
|
907
|
+
globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
|
908
|
+
globalConfig,
|
909
|
+
fakeUserId,
|
910
|
+
bffDataSource
|
911
|
+
]);
|
891
912
|
const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
892
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/like', { method: 'POST', body }));
|
913
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
|
893
914
|
return res === null || res === void 0 ? void 0 : res.success;
|
894
915
|
}), [bffFetch]);
|
895
916
|
const bffMutateUnlike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
896
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/unlike', { method: 'POST', body }));
|
917
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
|
897
918
|
return res === null || res === void 0 ? void 0 : res.success;
|
898
919
|
}), [bffFetch]);
|
899
920
|
const bffSubmitForm = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
900
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/customform', { method: 'POST', body }));
|
921
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
|
901
922
|
return res === null || res === void 0 ? void 0 : res.success;
|
902
923
|
}), [bffFetch]);
|
903
924
|
// 获取 Tag
|
@@ -912,7 +933,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
912
933
|
const key = val.split('=')[0];
|
913
934
|
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);
|
914
935
|
})) === null || _9 === void 0 ? void 0 : _9.join('&')) !== null && _10 !== void 0 ? _10 : '';
|
915
|
-
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
|
936
|
+
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
|
916
937
|
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 : []);
|
917
938
|
}
|
918
939
|
catch (e) {
|
@@ -986,10 +1007,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
986
1007
|
let curData;
|
987
1008
|
let gldata;
|
988
1009
|
if (data === null || data === void 0 ? void 0 : data.layoutVariantId) {
|
1010
|
+
layId = data === null || data === void 0 ? void 0 : data.layoutVariantId;
|
1011
|
+
setLayoutVariantId(data === null || data === void 0 ? void 0 : data.layoutVariantId);
|
989
1012
|
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];
|
990
1013
|
if (id) {
|
991
|
-
layId = id;
|
992
|
-
setLayoutVariantId(id);
|
993
1014
|
curData = dataList === null || dataList === void 0 ? void 0 : dataList.find((item) => (item === null || item === void 0 ? void 0 : item.id) === id);
|
994
1015
|
if (curData) {
|
995
1016
|
setPageData(curData);
|
@@ -10076,7 +10097,7 @@ var CommodityGroup$1 = memo(CommodityGroup);
|
|
10076
10097
|
* @Author: binruan@chatlabs.com
|
10077
10098
|
* @Date: 2024-03-20 14:56:16
|
10078
10099
|
* @LastEditors: binruan@chatlabs.com
|
10079
|
-
* @LastEditTime: 2024-
|
10100
|
+
* @LastEditTime: 2024-12-20 14:32:26
|
10080
10101
|
* @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
|
10081
10102
|
*
|
10082
10103
|
*/
|
@@ -10114,14 +10135,16 @@ const getBgStyle = (imgSrc) => {
|
|
10114
10135
|
};
|
10115
10136
|
const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
|
10116
10137
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
10138
|
+
let text = '';
|
10117
10139
|
if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
|
10118
10140
|
return null;
|
10119
|
-
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;
|
10120
|
-
|
10141
|
+
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);
|
10142
|
+
if (typeof price !== 'number')
|
10143
|
+
return text;
|
10121
10144
|
let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
|
10122
10145
|
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 : '' : '$';
|
10123
10146
|
const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
|
10124
|
-
let decPic = price.toString();
|
10147
|
+
let decPic = price === null || price === void 0 ? void 0 : price.toString();
|
10125
10148
|
if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
|
10126
10149
|
decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
|
10127
10150
|
}
|
@@ -11939,7 +11962,7 @@ const CommodityList = createMaterial(CommodityListComponent, {
|
|
11939
11962
|
* @Author: binruan@chatlabs.com
|
11940
11963
|
* @Date: 2023-10-27 14:06:35
|
11941
11964
|
* @LastEditors: binruan@chatlabs.com
|
11942
|
-
* @LastEditTime: 2024-
|
11965
|
+
* @LastEditTime: 2024-08-08 17:32:11
|
11943
11966
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
|
11944
11967
|
*
|
11945
11968
|
*/
|
@@ -11953,32 +11976,16 @@ var settingRender$8 = [
|
|
11953
11976
|
name: ['style', 'backgroundColor']
|
11954
11977
|
}
|
11955
11978
|
]
|
11956
|
-
},
|
11957
|
-
{
|
11958
|
-
title: 'iframe',
|
11959
|
-
child: [
|
11960
|
-
{
|
11961
|
-
type: 'TextArea',
|
11962
|
-
label: 'url',
|
11963
|
-
name: ['props', 'iframe', 'src']
|
11964
|
-
},
|
11965
|
-
{
|
11966
|
-
type: 'TextArea',
|
11967
|
-
label: 'allow',
|
11968
|
-
name: ['props', 'iframe', 'allow']
|
11969
|
-
}
|
11970
|
-
]
|
11971
11979
|
}
|
11972
11980
|
];
|
11973
11981
|
|
11974
11982
|
const Iframe$1 = (_a) => {
|
11975
11983
|
var _b, _c;
|
11976
|
-
var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel
|
11984
|
+
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"]);
|
11977
11985
|
const { popupDetailData } = useSxpDataSource();
|
11978
|
-
const
|
11979
|
-
|
11980
|
-
|
11981
|
-
React.createElement("iframe", { src: iframeUrl, allow: allow, scrolling: 'no', style: {
|
11986
|
+
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;
|
11987
|
+
return (React.createElement("div", Object.assign({ className: `${css(Object.assign({}, style))}` }, props),
|
11988
|
+
React.createElement("iframe", { src: iframeUrl, style: {
|
11982
11989
|
width: '100%',
|
11983
11990
|
height: 'calc(100% - 50px)',
|
11984
11991
|
marginTop: '50px',
|
@@ -17916,7 +17923,7 @@ var NavBack$1 = memo(NavBack);
|
|
17916
17923
|
* @Author: binruan@chatlabs.com
|
17917
17924
|
* @Date: 2024-03-20 10:27:31
|
17918
17925
|
* @LastEditors: binruan@chatlabs.com
|
17919
|
-
* @LastEditTime: 2024-12-
|
17926
|
+
* @LastEditTime: 2024-12-26 17:33:54
|
17920
17927
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
17921
17928
|
*
|
17922
17929
|
*/
|
@@ -18041,6 +18048,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
18041
18048
|
skipLinkRef.current = false;
|
18042
18049
|
}
|
18043
18050
|
// 页面可见时触发,注意页面初始化时不会触发
|
18051
|
+
refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
|
18044
18052
|
handleH5EnterLink();
|
18045
18053
|
if (repCond) {
|
18046
18054
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|
@@ -18883,7 +18891,7 @@ var index$1 = memo(DiyPortalPreview);
|
|
18883
18891
|
* @Author: binruan@chatlabs.com
|
18884
18892
|
* @Date: 2023-10-31 10:56:01
|
18885
18893
|
* @LastEditors: binruan@chatlabs.com
|
18886
|
-
* @LastEditTime: 2024-
|
18894
|
+
* @LastEditTime: 2024-10-23 15:07:29
|
18887
18895
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Popup\index.tsx
|
18888
18896
|
*
|
18889
18897
|
*/
|