pb-sxp-ui 1.19.0-alpha.3 → 1.19.0-alpha.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/pb-ui.js CHANGED
@@ -765,7 +765,27 @@
765
765
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
766
766
  }, [bffDataSource]);
767
767
  const getTargetingCookie = () => {
768
- var _a;
768
+ var _a, _b;
769
+ function isTargetingRejected(cookieValue) {
770
+ // 1. 从Cookie字符串中提取groups部分
771
+ const groupsMatch = cookieValue.match(/groups=([^&]+)/);
772
+ if (!groupsMatch || !groupsMatch[1]) {
773
+ return false;
774
+ }
775
+ const groupsString = groupsMatch[1];
776
+ // 2. 将groups字符串拆分为键值对数组
777
+ const groupsPairs = groupsString.split(',');
778
+ // 3. 遍历查找第四个类别(Targeting)的状态
779
+ for (const pair of groupsPairs) {
780
+ const [category, status] = pair.split(':');
781
+ if (category === '4') {
782
+ // 找到第四个类别,检查其状态
783
+ return status === '0'; // 如果状态为0则返回true
784
+ }
785
+ }
786
+ // 如果没有找到第四个类别
787
+ return false;
788
+ }
769
789
  function getCookie(name) {
770
790
  var _a;
771
791
  const value = `; ${document.cookie}`;
@@ -774,9 +794,8 @@
774
794
  return (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift();
775
795
  return '';
776
796
  }
777
- decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
778
- console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
779
- if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
797
+ const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
798
+ if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && ((_b = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) === null || _b === void 0 ? void 0 : _b.length) > 2 && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')) && isTargetingRejected(OptanonConsent))) {
780
799
  return true;
781
800
  }
782
801
  return false;
@@ -19017,6 +19036,7 @@ Made in Italy` })));
19017
19036
  const [isReload, setIsReload] = React.useState(new Date().getTime());
19018
19037
  const skipLinkRef = React.useRef(false);
19019
19038
  const [pageNum, setPageNum] = React.useState(2);
19039
+ const [isShowCookieSetting, setIsShowCookieSetting] = React.useState(false);
19020
19040
  const videoWidgetRef = React.useRef(null);
19021
19041
  const fbcRef = React.useRef('');
19022
19042
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5 } = useSxpDataSource();
@@ -19466,30 +19486,48 @@ Made in Italy` })));
19466
19486
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
19467
19487
  return;
19468
19488
  window.OptanonWrapper = function () {
19469
- var _a, _b;
19470
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19471
- if (!activeGroups)
19472
- return;
19473
- if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19474
- if (fbcRef.current) {
19475
- setCookie('_fbc', fbcRef.current, 90);
19476
- }
19489
+ var _a;
19490
+ console.log('OptanonWrapper');
19491
+ if ((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && ((_a = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) === null || _a === void 0 ? void 0 : _a.length) > 2) {
19492
+ setIsShowCookieSetting(true);
19477
19493
  }
19478
- else {
19479
- fbcRef.current = getCookie('_fbc');
19480
- deleteCookie('_fbc');
19481
- const item = data[activeIndex];
19482
- const traceInfo = ((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.traceInfo) || ((_b = item === null || item === void 0 ? void 0 : item.product) === null || _b === void 0 ? void 0 : _b.traceInfo) || '';
19483
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19484
- eventInfo: {
19485
- eventSubject: 'refuseCookie',
19486
- eventDescription: 'refuseCookie',
19487
- traceInfo
19488
- },
19489
- isActiveTargetingCookie: false
19490
- });
19494
+ };
19495
+ const handleClick = (event) => {
19496
+ var _a, _b;
19497
+ const beForeactiveGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19498
+ if (((_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('.ot-pc-refuse-all-handler')) || ((_b = event.target) === null || _b === void 0 ? void 0 : _b.closest('.save-preference-btn-handler'))) {
19499
+ window.OptanonWrapper = function () {
19500
+ var _a, _b;
19501
+ // 这里可以添加保存选择后的处理逻辑
19502
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19503
+ if (!activeGroups)
19504
+ return;
19505
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19506
+ if (fbcRef.current && !(beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4'))) {
19507
+ setCookie('_fbp', fbcRef.current, 90);
19508
+ }
19509
+ }
19510
+ else if (beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4')) {
19511
+ fbcRef.current = getCookie('_fbc');
19512
+ deleteCookie('_fbc');
19513
+ const item = data[activeIndex];
19514
+ const traceInfo = ((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.traceInfo) || ((_b = item === null || item === void 0 ? void 0 : item.product) === null || _b === void 0 ? void 0 : _b.traceInfo) || '';
19515
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19516
+ eventInfo: {
19517
+ eventSubject: 'refuseCookie',
19518
+ eventDescription: 'refuseCookie',
19519
+ traceInfo
19520
+ },
19521
+ isActiveTargetingCookie: false
19522
+ });
19523
+ }
19524
+ };
19491
19525
  }
19492
19526
  };
19527
+ document.addEventListener('click', handleClick);
19528
+ return () => {
19529
+ document.removeEventListener('click', handleClick);
19530
+ };
19493
19531
  }, [globalConfig, bffEventReport, data, activeIndex]);
19494
19532
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
19495
19533
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -19638,7 +19676,7 @@ Made in Italy` })));
19638
19676
  React.createElement(WaterFall$1, Object.assign({}, (_u = (_t = (_s = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.item) === null || _u === void 0 ? void 0 : _u.props)),
19639
19677
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19640
19678
  openMultiPosts && (React.createElement(MultiPosts$2, Object.assign({}, (_x = (_w = (_v = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.item) === null || _x === void 0 ? void 0 : _x.props, (_0 = (_z = (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.item) === null || _0 === void 0 ? void 0 : _0.event, { style: { position: 'fixed', top: 0, left: 0, right: 0 } }))))),
19641
- (window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (React.createElement("div", { style: { position: 'fixed', bottom: 0, left: 0, right: 0, width: '100%', zIndex: 10, backgroundColor: '#000', fontSize: 0 } },
19679
+ isShowCookieSetting && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (React.createElement("div", { style: { position: 'fixed', bottom: 0, left: 0, right: 0, width: '100%', zIndex: 10, backgroundColor: '#000', fontSize: 0 } },
19642
19680
  React.createElement("button", { id: 'ot-sdk-btn', className: 'ot-sdk-show-settings', style: { textDecoration: 'underline', width: 'fit-content', border: 'none', lineHeight: '24px', fontSize: '10px', color: '#fff', padding: '0 20px' } }, "Cookie settings")))));
19643
19681
  };
19644
19682
  var SxpPageRender$1 = React.memo(SxpPageRender);