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.cjs CHANGED
@@ -772,7 +772,27 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
772
772
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
773
773
  }, [bffDataSource]);
774
774
  const getTargetingCookie = () => {
775
- var _a;
775
+ var _a, _b;
776
+ function isTargetingRejected(cookieValue) {
777
+ // 1. 从Cookie字符串中提取groups部分
778
+ const groupsMatch = cookieValue.match(/groups=([^&]+)/);
779
+ if (!groupsMatch || !groupsMatch[1]) {
780
+ return false;
781
+ }
782
+ const groupsString = groupsMatch[1];
783
+ // 2. 将groups字符串拆分为键值对数组
784
+ const groupsPairs = groupsString.split(',');
785
+ // 3. 遍历查找第四个类别(Targeting)的状态
786
+ for (const pair of groupsPairs) {
787
+ const [category, status] = pair.split(':');
788
+ if (category === '4') {
789
+ // 找到第四个类别,检查其状态
790
+ return status === '0'; // 如果状态为0则返回true
791
+ }
792
+ }
793
+ // 如果没有找到第四个类别
794
+ return false;
795
+ }
776
796
  function getCookie(name) {
777
797
  var _a;
778
798
  const value = `; ${document.cookie}`;
@@ -781,9 +801,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
781
801
  return (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift();
782
802
  return '';
783
803
  }
784
- decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
785
- console.log('OptanonConsent:', window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups);
786
- if (((window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups) && !(window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups.includes('4')))) {
804
+ const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
805
+ 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))) {
787
806
  return true;
788
807
  }
789
808
  return false;
@@ -19024,6 +19043,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19024
19043
  const [isReload, setIsReload] = React.useState(new Date().getTime());
19025
19044
  const skipLinkRef = React.useRef(false);
19026
19045
  const [pageNum, setPageNum] = React.useState(2);
19046
+ const [isShowCookieSetting, setIsShowCookieSetting] = React.useState(false);
19027
19047
  const videoWidgetRef = React.useRef(null);
19028
19048
  const fbcRef = React.useRef('');
19029
19049
  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();
@@ -19473,30 +19493,48 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19473
19493
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
19474
19494
  return;
19475
19495
  window.OptanonWrapper = function () {
19476
- var _a, _b;
19477
- const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19478
- if (!activeGroups)
19479
- return;
19480
- if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19481
- if (fbcRef.current) {
19482
- setCookie('_fbc', fbcRef.current, 90);
19483
- }
19496
+ var _a;
19497
+ console.log('OptanonWrapper');
19498
+ 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) {
19499
+ setIsShowCookieSetting(true);
19484
19500
  }
19485
- else {
19486
- fbcRef.current = getCookie('_fbc');
19487
- deleteCookie('_fbc');
19488
- const item = data[activeIndex];
19489
- 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) || '';
19490
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19491
- eventInfo: {
19492
- eventSubject: 'refuseCookie',
19493
- eventDescription: 'refuseCookie',
19494
- traceInfo
19495
- },
19496
- isActiveTargetingCookie: false
19497
- });
19501
+ };
19502
+ const handleClick = (event) => {
19503
+ var _a, _b;
19504
+ const beForeactiveGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19505
+ 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'))) {
19506
+ window.OptanonWrapper = function () {
19507
+ var _a, _b;
19508
+ // 这里可以添加保存选择后的处理逻辑
19509
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19510
+ if (!activeGroups)
19511
+ return;
19512
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19513
+ if (fbcRef.current && !(beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4'))) {
19514
+ setCookie('_fbp', fbcRef.current, 90);
19515
+ }
19516
+ }
19517
+ else if (beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4')) {
19518
+ fbcRef.current = getCookie('_fbc');
19519
+ deleteCookie('_fbc');
19520
+ const item = data[activeIndex];
19521
+ 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) || '';
19522
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19523
+ eventInfo: {
19524
+ eventSubject: 'refuseCookie',
19525
+ eventDescription: 'refuseCookie',
19526
+ traceInfo
19527
+ },
19528
+ isActiveTargetingCookie: false
19529
+ });
19530
+ }
19531
+ };
19498
19532
  }
19499
19533
  };
19534
+ document.addEventListener('click', handleClick);
19535
+ return () => {
19536
+ document.removeEventListener('click', handleClick);
19537
+ };
19500
19538
  }, [globalConfig, bffEventReport, data, activeIndex]);
19501
19539
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
19502
19540
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -19645,7 +19683,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19645
19683
  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)),
19646
19684
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19647
19685
  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 } }))))),
19648
- (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 } },
19686
+ 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 } },
19649
19687
  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")))));
19650
19688
  };
19651
19689
  var SxpPageRender$1 = React.memo(SxpPageRender);