pb-sxp-ui 1.13.1 → 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/index.cjs +22 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -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 +22 -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/context/SxpDataSourceProvider.js +18 -39
- package/es/core/utils/materials.js +3 -5
- package/lib/core/context/SxpDataSourceProvider.js +18 -39
- package/lib/core/utils/materials.js +3 -5
- package/package.json +1 -1
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
|
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
|
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
|
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('
|
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('
|
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(
|
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
|
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:
|
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(
|
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('
|
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('
|
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('
|
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('
|
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-
|
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 =
|
10157
|
-
|
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
|
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
|
}
|