pb-sxp-ui 1.19.0-alpha.3 → 1.19.0-alpha.5

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
@@ -285,33 +285,6 @@ function deleteCookie(name, path = '/', domain = '') {
285
285
  document.cookie = `${name}=; ${expiration}${pathPart}${domainPart}`;
286
286
  console.log(`已尝试删除Cookie: ${name}`);
287
287
  }
288
- function setCookie(name, value, days = 0, path = '/', domain = '', secure = false, sameSite = 'Lax') {
289
- let cookieString = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
290
- // 设置过期时间
291
- if (days) {
292
- const date = new Date();
293
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
294
- cookieString += `; expires=${date.toUTCString()}`;
295
- }
296
- // 设置路径
297
- if (path) {
298
- cookieString += `; path=${path}`;
299
- }
300
- // 设置域名
301
- if (domain) {
302
- cookieString += `; domain=${domain}`;
303
- }
304
- // 设置Secure标志
305
- if (secure) {
306
- cookieString += '; secure';
307
- }
308
- // 设置SameSite属性
309
- if (sameSite) {
310
- cookieString += `; samesite=${sameSite}`;
311
- }
312
- // 设置Cookie
313
- document.cookie = cookieString;
314
- }
315
288
 
316
289
  function unzip(b64Data) {
317
290
  const strData = atob(b64Data);
@@ -750,7 +723,27 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
750
723
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
751
724
  }, [bffDataSource]);
752
725
  const getTargetingCookie = () => {
753
- var _a;
726
+ var _a, _b;
727
+ function isTargetingRejected(cookieValue) {
728
+ // 1. 从Cookie字符串中提取groups部分
729
+ const groupsMatch = cookieValue.match(/groups=([^&]+)/);
730
+ if (!groupsMatch || !groupsMatch[1]) {
731
+ return false;
732
+ }
733
+ const groupsString = groupsMatch[1];
734
+ // 2. 将groups字符串拆分为键值对数组
735
+ const groupsPairs = groupsString.split(',');
736
+ // 3. 遍历查找第四个类别(Targeting)的状态
737
+ for (const pair of groupsPairs) {
738
+ const [category, status] = pair.split(':');
739
+ if (category === '4') {
740
+ // 找到第四个类别,检查其状态
741
+ return status === '0'; // 如果状态为0则返回true
742
+ }
743
+ }
744
+ // 如果没有找到第四个类别
745
+ return false;
746
+ }
754
747
  function getCookie(name) {
755
748
  var _a;
756
749
  const value = `; ${document.cookie}`;
@@ -759,9 +752,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
759
752
  return (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift();
760
753
  return '';
761
754
  }
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')))) {
755
+ const OptanonConsent = decodeURIComponent((_a = getCookie('OptanonConsent')) !== null && _a !== void 0 ? _a : '');
756
+ 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
757
  return true;
766
758
  }
767
759
  return false;
@@ -19002,6 +18994,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19002
18994
  const [isReload, setIsReload] = useState(new Date().getTime());
19003
18995
  const skipLinkRef = useRef(false);
19004
18996
  const [pageNum, setPageNum] = useState(2);
18997
+ const [isShowCookieSetting, setIsShowCookieSetting] = useState(false);
19005
18998
  const videoWidgetRef = useRef(null);
19006
18999
  const fbcRef = useRef('');
19007
19000
  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 +19444,46 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19451
19444
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting))
19452
19445
  return;
19453
19446
  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
- }
19447
+ var _a;
19448
+ console.log('OptanonWrapper');
19449
+ 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) {
19450
+ setIsShowCookieSetting(true);
19462
19451
  }
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
- });
19452
+ };
19453
+ const handleClick = (event) => {
19454
+ var _a, _b;
19455
+ const beForeactiveGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19456
+ 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'))) {
19457
+ window.OptanonWrapper = function () {
19458
+ var _a, _b;
19459
+ // 这里可以添加保存选择后的处理逻辑
19460
+ const activeGroups = window === null || window === void 0 ? void 0 : window.OnetrustActiveGroups;
19461
+ if (!activeGroups)
19462
+ return;
19463
+ if (activeGroups === null || activeGroups === void 0 ? void 0 : activeGroups.includes('4')) {
19464
+ if (fbcRef.current && !(beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4'))) ;
19465
+ }
19466
+ else if (beForeactiveGroups === null || beForeactiveGroups === void 0 ? void 0 : beForeactiveGroups.includes('4')) {
19467
+ fbcRef.current = getCookie('_fbp');
19468
+ deleteCookie('_fbp');
19469
+ const item = data[activeIndex];
19470
+ 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) || '';
19471
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
19472
+ eventInfo: {
19473
+ eventSubject: 'refuseCookie',
19474
+ eventDescription: 'refuseCookie',
19475
+ traceInfo
19476
+ },
19477
+ isActiveTargetingCookie: false
19478
+ });
19479
+ }
19480
+ };
19476
19481
  }
19477
19482
  };
19483
+ document.addEventListener('click', handleClick);
19484
+ return () => {
19485
+ document.removeEventListener('click', handleClick);
19486
+ };
19478
19487
  }, [globalConfig, bffEventReport, data, activeIndex]);
19479
19488
  const handleViewImageStartEvent = (activeIndex, imgInfo, enableCapi) => {
19480
19489
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -19623,7 +19632,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19623
19632
  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
19633
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
19625
19634
  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 } },
19635
+ 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
19636
  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
19637
  };
19629
19638
  var SxpPageRender$1 = memo(SxpPageRender);