pb-sxp-ui 1.13.0 → 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 +44 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -51
- 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 +44 -51
- 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/es/materials/sxp/popup/Iframe/index.d.ts +4 -0
- package/es/materials/sxp/popup/Iframe/index.js +5 -4
- package/es/materials/sxp/popup/Iframe/settingRender.js +15 -0
- package/lib/core/context/SxpDataSourceProvider.js +18 -39
- package/lib/core/utils/materials.js +3 -5
- package/lib/materials/sxp/popup/Iframe/index.d.ts +4 -0
- package/lib/materials/sxp/popup/Iframe/index.js +5 -4
- package/lib/materials/sxp/popup/Iframe/settingRender.js +15 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -677,15 +677,12 @@ 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]);
|
684
680
|
// bff API 请求方法
|
685
681
|
const bffFetch = React.useCallback((path, options) => {
|
686
682
|
if (!bffDataSource)
|
687
683
|
return;
|
688
684
|
const url = bffDataSource.url;
|
685
|
+
const fakeUserId = storeAndLoadFeUserId();
|
689
686
|
if (options === null || options === void 0 ? void 0 : options.query) {
|
690
687
|
const queryString = qs.stringify(options.query);
|
691
688
|
path = `${path}?${queryString}`;
|
@@ -693,19 +690,19 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
693
690
|
// 事件上报优化
|
694
691
|
// Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
|
695
692
|
if (options.type === 'beacon' && navigator.sendBeacon) {
|
696
|
-
return navigator.sendBeacon(`${url}/api
|
693
|
+
return navigator.sendBeacon(`${url}/api/v1${path}`, new Blob([
|
697
694
|
JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))
|
698
695
|
], { type: 'application/json;charset=UTF-8' }));
|
699
696
|
}
|
700
697
|
return window
|
701
|
-
.fetch(`${url}/api
|
698
|
+
.fetch(`${url}/api/v1${path}`, {
|
702
699
|
headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
|
703
700
|
method: options.method,
|
704
701
|
body: JSON.stringify(options.body)
|
705
702
|
})
|
706
703
|
.then((res) => res.json())
|
707
704
|
.catch((err) => Promise.reject(err));
|
708
|
-
}, [bffDataSource
|
705
|
+
}, [bffDataSource]);
|
709
706
|
// 获取推荐视频数据
|
710
707
|
const getRecommendVideos = React.useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
|
711
708
|
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
@@ -743,7 +740,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
743
740
|
const recurveRecList = (query) => __awaiter(void 0, void 0, void 0, function* () {
|
744
741
|
var _v, _w, _x, _y, _z, _0;
|
745
742
|
query.pageNum = pageNum;
|
746
|
-
result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
743
|
+
result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
|
747
744
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
748
745
|
return undefined;
|
749
746
|
}
|
@@ -765,7 +762,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
765
762
|
if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) {
|
766
763
|
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 });
|
767
764
|
}
|
768
|
-
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
765
|
+
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'POST', body: query }));
|
769
766
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
770
767
|
return undefined;
|
771
768
|
}
|
@@ -815,7 +812,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
815
812
|
return expire;
|
816
813
|
}, [data]);
|
817
814
|
const bffEventReport = React.useCallback(({ userInfo, eventInfo, reportLayId = true }) => {
|
818
|
-
var _a;
|
819
815
|
// 关闭 BFF 事件上报
|
820
816
|
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
821
817
|
return;
|
@@ -837,23 +833,14 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
837
833
|
console.log('userInfo:', userInfo);
|
838
834
|
console.log('eventInfo:', ef);
|
839
835
|
console.log('========= 结束 =========');
|
840
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(
|
836
|
+
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/event/report', {
|
841
837
|
method: 'POST',
|
842
838
|
body: { userInfo: realUserInfo, eventInfo: realEventInfo },
|
843
839
|
type: 'beacon'
|
844
840
|
});
|
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
|
-
]);
|
841
|
+
}, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, layoutVariantId, globalConfig, playbookType]);
|
855
842
|
const bffFbReport = React.useCallback(({ eventName, product }) => {
|
856
|
-
var _a, _b, _c, _d, _e
|
843
|
+
var _a, _b, _c, _d, _e;
|
857
844
|
if (!enableReportEvent ||
|
858
845
|
!enabledMetaConversionApi ||
|
859
846
|
(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) ||
|
@@ -865,7 +852,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
865
852
|
const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
|
866
853
|
const fix_par = {
|
867
854
|
event_source_url: (_c = window === null || window === void 0 ? void 0 : window.location) === null || _c === void 0 ? void 0 : _c.href,
|
868
|
-
external_id:
|
855
|
+
external_id: storeAndLoadFeUserId(),
|
869
856
|
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 : '',
|
870
857
|
fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
|
871
858
|
fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
|
@@ -917,30 +904,22 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
917
904
|
}
|
918
905
|
};
|
919
906
|
getEventParams(jsonParams);
|
920
|
-
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch(
|
907
|
+
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
|
921
908
|
method: 'POST',
|
922
909
|
body: jsonParams,
|
923
910
|
type: 'beacon'
|
924
911
|
});
|
925
|
-
}, [
|
926
|
-
bffFetch,
|
927
|
-
enableReportEvent,
|
928
|
-
enabledMetaConversionApi,
|
929
|
-
globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview,
|
930
|
-
globalConfig,
|
931
|
-
fakeUserId,
|
932
|
-
bffDataSource
|
933
|
-
]);
|
912
|
+
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, globalConfig]);
|
934
913
|
const bffMutateLike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
935
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
914
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/like', { method: 'POST', body }));
|
936
915
|
return res === null || res === void 0 ? void 0 : res.success;
|
937
916
|
}), [bffFetch]);
|
938
917
|
const bffMutateUnlike = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
939
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
918
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/unlike', { method: 'POST', body }));
|
940
919
|
return res === null || res === void 0 ? void 0 : res.success;
|
941
920
|
}), [bffFetch]);
|
942
921
|
const bffSubmitForm = React.useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
943
|
-
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
922
|
+
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/customform', { method: 'POST', body }));
|
944
923
|
return res === null || res === void 0 ? void 0 : res.success;
|
945
924
|
}), [bffFetch]);
|
946
925
|
// 获取 Tag
|
@@ -955,7 +934,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
955
934
|
const key = val.split('=')[0];
|
956
935
|
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);
|
957
936
|
})) === null || _9 === void 0 ? void 0 : _9.join('&')) !== null && _10 !== void 0 ? _10 : '';
|
958
|
-
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('
|
937
|
+
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
|
959
938
|
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 : []);
|
960
939
|
}
|
961
940
|
catch (e) {
|
@@ -1029,10 +1008,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
1029
1008
|
let curData;
|
1030
1009
|
let gldata;
|
1031
1010
|
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);
|
1034
1011
|
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];
|
1035
1012
|
if (id) {
|
1013
|
+
layId = id;
|
1014
|
+
setLayoutVariantId(id);
|
1036
1015
|
curData = dataList === null || dataList === void 0 ? void 0 : dataList.find((item) => (item === null || item === void 0 ? void 0 : item.id) === id);
|
1037
1016
|
if (curData) {
|
1038
1017
|
setPageData(curData);
|
@@ -10119,7 +10098,7 @@ var CommodityGroup$1 = React.memo(CommodityGroup);
|
|
10119
10098
|
* @Author: binruan@chatlabs.com
|
10120
10099
|
* @Date: 2024-03-20 14:56:16
|
10121
10100
|
* @LastEditors: binruan@chatlabs.com
|
10122
|
-
* @LastEditTime: 2024-
|
10101
|
+
* @LastEditTime: 2024-10-24 17:51:19
|
10123
10102
|
* @FilePath: \pb-sxp-ui\src\core\utils\materials.ts
|
10124
10103
|
*
|
10125
10104
|
*/
|
@@ -10157,16 +10136,14 @@ const getBgStyle = (imgSrc) => {
|
|
10157
10136
|
};
|
10158
10137
|
const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
|
10159
10138
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
10160
|
-
let text = '';
|
10161
10139
|
if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
|
10162
10140
|
return null;
|
10163
|
-
let price =
|
10164
|
-
|
10165
|
-
return text;
|
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
|
+
let text = '';
|
10166
10143
|
let priceSymbol = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol;
|
10167
10144
|
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 : '' : '$';
|
10168
10145
|
const isToLocStr = enableFormattedPrice === undefined || enableFormattedPrice;
|
10169
|
-
let decPic = price
|
10146
|
+
let decPic = price.toString();
|
10170
10147
|
if (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.showTwoDecimalPoint) {
|
10171
10148
|
decPic = price === null || price === void 0 ? void 0 : price.toFixed(2);
|
10172
10149
|
}
|
@@ -11984,7 +11961,7 @@ const CommodityList = createMaterial(CommodityListComponent, {
|
|
11984
11961
|
* @Author: binruan@chatlabs.com
|
11985
11962
|
* @Date: 2023-10-27 14:06:35
|
11986
11963
|
* @LastEditors: binruan@chatlabs.com
|
11987
|
-
* @LastEditTime: 2024-
|
11964
|
+
* @LastEditTime: 2024-12-12 15:12:57
|
11988
11965
|
* @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
|
11989
11966
|
*
|
11990
11967
|
*/
|
@@ -11998,16 +11975,32 @@ var settingRender$8 = [
|
|
11998
11975
|
name: ['style', 'backgroundColor']
|
11999
11976
|
}
|
12000
11977
|
]
|
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
|
+
]
|
12001
11993
|
}
|
12002
11994
|
];
|
12003
11995
|
|
12004
11996
|
const Iframe$1 = (_a) => {
|
12005
11997
|
var _b, _c;
|
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"]);
|
11998
|
+
var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle, isTel, iframe } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle", "isTel", "iframe"]);
|
12007
11999
|
const { popupDetailData } = useSxpDataSource();
|
12008
|
-
const
|
12009
|
-
|
12010
|
-
|
12000
|
+
const { src, allow } = iframe || {};
|
12001
|
+
const iframeUrl = src || ((_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);
|
12002
|
+
return (React.createElement("div", Object.assign({ className: `${css.css(Object.assign(Object.assign({}, style), { overflow: 'hidden' }))}` }, props),
|
12003
|
+
React.createElement("iframe", { src: iframeUrl, allow: allow, scrolling: 'no', style: {
|
12011
12004
|
width: '100%',
|
12012
12005
|
height: 'calc(100% - 50px)',
|
12013
12006
|
marginTop: '50px',
|
@@ -18912,7 +18905,7 @@ var index$1 = React.memo(DiyPortalPreview);
|
|
18912
18905
|
* @Author: binruan@chatlabs.com
|
18913
18906
|
* @Date: 2023-10-31 10:56:01
|
18914
18907
|
* @LastEditors: binruan@chatlabs.com
|
18915
|
-
* @LastEditTime: 2024-
|
18908
|
+
* @LastEditTime: 2024-12-12 14:48:31
|
18916
18909
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\Popup\index.tsx
|
18917
18910
|
*
|
18918
18911
|
*/
|