pb-sxp-ui 1.13.3 → 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 +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/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
|
}
|
@@ -17900,7 +17923,7 @@ var NavBack$1 = memo(NavBack);
|
|
17900
17923
|
* @Author: binruan@chatlabs.com
|
17901
17924
|
* @Date: 2024-03-20 10:27:31
|
17902
17925
|
* @LastEditors: binruan@chatlabs.com
|
17903
|
-
* @LastEditTime: 2024-12-
|
17926
|
+
* @LastEditTime: 2024-12-26 17:33:54
|
17904
17927
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
17905
17928
|
*
|
17906
17929
|
*/
|
@@ -18025,6 +18048,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
18025
18048
|
skipLinkRef.current = false;
|
18026
18049
|
}
|
18027
18050
|
// 页面可见时触发,注意页面初始化时不会触发
|
18051
|
+
refreshFeSession === null || refreshFeSession === void 0 ? void 0 : refreshFeSession(false, handleSessionCompleted);
|
18028
18052
|
handleH5EnterLink();
|
18029
18053
|
if (repCond) {
|
18030
18054
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|