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.js
CHANGED
@@ -714,6 +714,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
714
714
|
}, [bffDataSource]);
|
715
715
|
// bff API 请求方法
|
716
716
|
const bffFetch = useCallback((path, options) => {
|
717
|
+
var _a, _b;
|
717
718
|
if (!bffDataSource)
|
718
719
|
return;
|
719
720
|
const url = bffDataSource.url;
|
@@ -721,13 +722,49 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
721
722
|
const queryString = qs.stringify(options.query);
|
722
723
|
path = `${path}?${queryString}`;
|
723
724
|
}
|
725
|
+
let isTikTokChannel = false;
|
726
|
+
const params = {};
|
727
|
+
const queryString = location.search.slice(1);
|
728
|
+
(_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
729
|
+
const key = val.split('=')[0];
|
730
|
+
const value = val.split('=')[1];
|
731
|
+
params[key] = value;
|
732
|
+
});
|
733
|
+
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
734
|
+
if (cl_source &&
|
735
|
+
((_b = [
|
736
|
+
'40A-SPRK--DRESS_EYEWEAR-',
|
737
|
+
'41A-SPRK--MADRAGUE-',
|
738
|
+
'42A-SPRK--MOOD-',
|
739
|
+
'43A-SPRK--SUMMER-',
|
740
|
+
'44A-SPRK--DRESS_EYEWEAR-',
|
741
|
+
'45A-SPRK--MADRAGUE-',
|
742
|
+
'46A-SPRK--MOOD-',
|
743
|
+
'47A-SPRK--SUMMER-',
|
744
|
+
'48A-SPRK--DRESS_EYEWEAR-',
|
745
|
+
'49A-SPRK--MADRAGUE-',
|
746
|
+
'50A-SPRK--MOOD-',
|
747
|
+
'51A-SPRK--SUMMER-'
|
748
|
+
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
749
|
+
isTikTokChannel = true;
|
750
|
+
}
|
751
|
+
// 事件上报优化
|
752
|
+
// Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
|
753
|
+
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
754
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
755
|
+
JSON.stringify({
|
756
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
757
|
+
})
|
758
|
+
], {
|
759
|
+
type: 'application/json;charset=UTF-8'
|
760
|
+
}));
|
761
|
+
}
|
724
762
|
return window
|
725
|
-
.fetch(`${url}/api/${path}`, {
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
})
|
763
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
|
764
|
+
? JSON.stringify({
|
765
|
+
body: btoa(encodeURIComponent(JSON.stringify(options.body)))
|
766
|
+
})
|
767
|
+
: JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
|
731
768
|
.then((res) => res.json())
|
732
769
|
.catch((err) => Promise.reject(err));
|
733
770
|
}, [bffDataSource, fakeUserId]);
|