pb-sxp-ui 1.15.20-alpha.5 → 1.15.20
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 +43 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -6
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +43 -6
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/context/SxpDataSourceProvider.js +41 -6
- package/lib/core/context/SxpDataSourceProvider.js +41 -6
- package/package.json +1 -2
- package/es/core/utils/cryptojs.d.ts +0 -3
- package/es/core/utils/cryptojs.js +0 -18
- package/lib/core/utils/cryptojs.d.ts +0 -3
- package/lib/core/utils/cryptojs.js +0 -23
package/dist/index.cjs
CHANGED
@@ -736,6 +736,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
736
736
|
}, [bffDataSource]);
|
737
737
|
// bff API 请求方法
|
738
738
|
const bffFetch = React.useCallback((path, options) => {
|
739
|
+
var _a, _b;
|
739
740
|
if (!bffDataSource)
|
740
741
|
return;
|
741
742
|
const url = bffDataSource.url;
|
@@ -743,13 +744,49 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
743
744
|
const queryString = qs.stringify(options.query);
|
744
745
|
path = `${path}?${queryString}`;
|
745
746
|
}
|
747
|
+
let isTikTokChannel = false;
|
748
|
+
const params = {};
|
749
|
+
const queryString = location.search.slice(1);
|
750
|
+
(_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
751
|
+
const key = val.split('=')[0];
|
752
|
+
const value = val.split('=')[1];
|
753
|
+
params[key] = value;
|
754
|
+
});
|
755
|
+
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
756
|
+
if (cl_source &&
|
757
|
+
((_b = [
|
758
|
+
'40A-SPRK--DRESS_EYEWEAR-',
|
759
|
+
'41A-SPRK--MADRAGUE-',
|
760
|
+
'42A-SPRK--MOOD-',
|
761
|
+
'43A-SPRK--SUMMER-',
|
762
|
+
'44A-SPRK--DRESS_EYEWEAR-',
|
763
|
+
'45A-SPRK--MADRAGUE-',
|
764
|
+
'46A-SPRK--MOOD-',
|
765
|
+
'47A-SPRK--SUMMER-',
|
766
|
+
'48A-SPRK--DRESS_EYEWEAR-',
|
767
|
+
'49A-SPRK--MADRAGUE-',
|
768
|
+
'50A-SPRK--MOOD-',
|
769
|
+
'51A-SPRK--SUMMER-'
|
770
|
+
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
771
|
+
isTikTokChannel = true;
|
772
|
+
}
|
773
|
+
// 事件上报优化
|
774
|
+
// Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
|
775
|
+
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
776
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
777
|
+
JSON.stringify({
|
778
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
779
|
+
})
|
780
|
+
], {
|
781
|
+
type: 'application/json;charset=UTF-8'
|
782
|
+
}));
|
783
|
+
}
|
746
784
|
return window
|
747
|
-
.fetch(`${url}/api/${path}`, {
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
})
|
785
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
|
786
|
+
? JSON.stringify({
|
787
|
+
body: btoa(encodeURIComponent(JSON.stringify(options.body)))
|
788
|
+
})
|
789
|
+
: JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
|
753
790
|
.then((res) => res.json())
|
754
791
|
.catch((err) => Promise.reject(err));
|
755
792
|
}, [bffDataSource, fakeUserId]);
|