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/index.js CHANGED
@@ -750,7 +750,27 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
750
750
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
751
751
  }, [bffDataSource]);
752
752
  const getTargetingCookie = () => {
753
- var _a;
753
+ var _a, _b;
754
+ function isTargetingRejected(cookieValue) {
755
+ // 1. 从Cookie字符串中提取groups部分
756
+ const groupsMatch = cookieValue.match(/groups=([^&]+)/);
757
+ if (!groupsMatch || !groupsMatch[1]) {
758
+ return false;
759
+ }
760
+ const groupsString = groupsMatch[1];
761
+ // 2. 将groups字符串拆分为键值对数组
762
+ const groupsPairs = groupsString.split(',');
763
+ // 3. 遍历查找第四个类别(Targeting)的状态
764
+ for (const pair of groupsPairs) {
765
+ const [category, status] = pair.split(':');
766
+ if (category === '4') {
767
+ // 找到第四个类别,检查其状态
768
+ return status === '0'; // 如果状态为0则返回true
769
+ }
770
+ }
771
+ // 如果没有找到第四个类别
772
+ return false;
773
+ }
754
774
  function getCookie(name) {
755
775
  var _a;
756
776
  const value = `; ${document.cookie}`;
@@ -759,9 +779,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
759
779
  return (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift();
760
780
  return '';
761
781
  }
762
- decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
763
- console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
764
- if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
782
+ const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
783
+ 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))) {
765
784
  return true;
766
785
  }
767
786
  return false;
@@ -19002,6 +19021,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19002
19021
  const [isReload, setIsReload] = useState(new Date().getTime());
19003
19022
  const skipLinkRef = useRef(false);
19004
19023
  const [pageNum, setPageNum] = useState(2);
19024
+ const [isShowCookieSetting, setIsShowCookieSetting] = useState(false);
19005
19025
  const videoWidgetRef = useRef(null);
19006
19026
  const fbcRef = useRef('');
19007
19027
  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();
@@ -19451,30 +19471,48 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19451
19471
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
19452
19472
  return;
19453
19473
  window.OptanonWrapper = function () {
19454
- var _a, _b;
19455
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19456
- if (!activeGroups)
19457
- return;
19458
- if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19459
- if (fbcRef.current) {
19460
- setCookie('_fbc', fbcRef.current, 90);
19461
- }
19474
+ var _a;
19475
+ console.log('OptanonWrapper');
19476
+ 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) {
19477
+ setIsShowCookieSetting(true);
19462
19478
  }
19463
- else {
19464
- fbcRef.current = getCookie('_fbc');
19465
- deleteCookie('_fbc');
19466
- const item = data[activeIndex];
19467
- 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) || '';
19468
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19469
- eventInfo: {
19470
- eventSubject: 'refuseCookie',
19471
- eventDescription: 'refuseCookie',
19472
- traceInfo
19473
- },
19474
- isActiveTargetingCookie: false
19475
- });
19479
+ };
19480
+ const handleClick = (event) => {
19481
+ var _a, _b;
19482
+ const beForeactiveGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19483
+ 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'))) {
19484
+ window.OptanonWrapper = function () {
19485
+ var _a, _b;
19486
+ // 这里可以添加保存选择后的处理逻辑
19487
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19488
+ if (!activeGroups)
19489
+ return;
19490
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19491
+ if (fbcRef.current && !(beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4'))) {
19492
+ setCookie('_fbp', fbcRef.current, 90);
19493
+ }
19494
+ }
19495
+ else if (beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4')) {
19496
+ fbcRef.current = getCookie('_fbc');
19497
+ deleteCookie('_fbc');
19498
+ const item = data[activeIndex];
19499
+ 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) || '';
19500
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19501
+ eventInfo: {
19502
+ eventSubject: 'refuseCookie',
19503
+ eventDescription: 'refuseCookie',
19504
+ traceInfo
19505
+ },
19506
+ isActiveTargetingCookie: false
19507
+ });
19508
+ }
19509
+ };
19476
19510
  }
19477
19511
  };
19512
+ document.addEventListener('click', handleClick);
19513
+ return () => {
19514
+ document.removeEventListener('click', handleClick);
19515
+ };
19478
19516
  }, [globalConfig, bffEventReport, data, activeIndex]);
19479
19517
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
19480
19518
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -19623,7 +19661,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19623
19661
  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)),
19624
19662
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19625
19663
  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 } }))))),
19626
- (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 } },
19664
+ 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 } },
19627
19665
  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")))));
19628
19666
  };
19629
19667
  var SxpPageRender$1 = memo(SxpPageRender);