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 +47 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -23
- 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 +47 -23
- 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/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/package.json +1 -1
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
|
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
|
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(
|
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
|
-
}, [
|
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:
|
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(
|
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
|
-
}, [
|
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-
|
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
|
-
|
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
|
}
|
@@ -17915,7 +17938,7 @@ Made in Italy` })));
|
|
17915
17938
|
* @Author: binruan@chatlabs.com
|
17916
17939
|
* @Date: 2024-03-20 10:27:31
|
17917
17940
|
* @LastEditors: binruan@chatlabs.com
|
17918
|
-
* @LastEditTime:
|
17941
|
+
* @LastEditTime: 2025-01-03 17:10:56
|
17919
17942
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
17920
17943
|
*
|
17921
17944
|
*/
|
@@ -18040,6 +18063,7 @@ Made in Italy` })));
|
|
18040
18063
|
skipLinkRef.current = false;
|
18041
18064
|
}
|
18042
18065
|
// 页面可见时触发,注意页面初始化时不会触发
|
18066
|
+
refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false);
|
18043
18067
|
handleH5EnterLink();
|
18044
18068
|
if (repCond) {
|
18045
18069
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|