(() => { const { EventManager, utils, actions, constants } = ShopbySkin; const { isMobileDevice } = utils; const headerEl = document.querySelector('shopby-header-v2'); // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.initialize({ apiOption: { platform: 'PC', }, }).then(() => { EventManager.fire('QUERY_PAGE_SCRIPTS', ShopbyExternalScript?.scripts); }); // 클릭이벤트 맵 const headerActionMap = { SIGN_OUT: async () => { await actions.postSignOut(); utils.moveTo({ url: constants.PAGE.MAIN, }); }, GO_MY_MENU: (e) => { if (!utils.isSignedIn()) { e.preventDefault(); const from = e.target.href; const nextUrl = `${location.origin}/pages/sign-in/sign-in.html`; location.href = `${nextUrl}?from=${encodeURIComponent(from)}`; } }, }; const clickEventListener = (e) => { const action = e?.target?.closest('[shopby-action]')?.getAttribute('shopby-action'); headerActionMap[action]?.(e); }; // 핵심: 페이지 로드가 완료된 후 로고를 제어합니다. EventManager.on('PAGE_LOAD_COMPLETED', ({ profile }) => { EventManager.fire('INIT_CATEGORY_SLIDER', { direction: 'horizontal', effect: 'slide', slidesPerView: 'auto', spaceBetween: 20, }); ShopbyExternalScript?.setGlobalObjectSb({ getPlatform: () => (isMobileDevice ? 'MOBILE_WEB' : 'PC'), profile, }); /* --- GNB 및 로고 커스텀 로직 시작 --- */ const currentPath = window.location.pathname; const isMainPage = currentPath === '/' || currentPath.includes('index.html'); // 1. GNB 메뉴 활성화 (기존 로직 유지) setTimeout(() => { const menuLinks = document.querySelectorAll('.new-gnb-menu a'); const currentPathWithSearch = window.location.pathname + window.location.search; menuLinks.forEach(link => { const href = link.getAttribute('href'); if (href && href !== '#') { if (href === '/' || href.includes('index.html')) { if (isMainPage) link.classList.add('active'); } else if (href.includes('event-detail') && window.location.pathname.includes('event-detail')) { link.classList.add('active'); } else if (currentPathWithSearch.includes(href)) { link.classList.add('active'); } } link.addEventListener('click', function() { menuLinks.forEach(item => item.classList.remove('active')); this.classList.add('active'); }); }); }, 500); // 2. 로고 분기 제어 (강력한 스타일 부여) const setLogoDisplay = () => { const mainLogo = document.querySelector('.logo-main'); const subLogo = document.querySelector('.logo-sub'); if (mainLogo && subLogo) { if (isMainPage) { mainLogo.style.display = 'block'; subLogo.style.display = 'none'; } else { mainLogo.style.display = 'none'; subLogo.style.display = 'block'; } } }; // 즉시 실행 및 약간의 지연 실행 (렌더링 타이밍 대응) setLogoDisplay(); setTimeout(setLogoDisplay, 100); /* --- 커스텀 로직 끝 --- */ }); headerEl?.addEventListener('click', clickEventListener); const searchParams = new URLSearchParams(location.search); const { setTrackingKey, setChannelType } = ShopbySkin.utils; setTrackingKey(searchParams.get('trackingKey')); setChannelType(searchParams.get('channelType')); })();