Twotrees Store
.header-wrapper--border-bottom:hover .header__heading-logo,
sticky-header .header__heading-logo {
filter: invert(1);
transition: filter 0.3s ease;
}
@media(max-width: 989px) {
.header-wrapper--border-bottom:hover .header__heading-logo,
sticky-header .header__heading-logo {
max-width: 75px;
}
}
document.addEventListener('DOMContentLoaded', function () {
// 创建一个观察器实例
const observer = new MutationObserver(function(mutations) {
const motherBoxes = document.querySelectorAll('.sales-box');
if (motherBoxes.length > 0) {
motherBoxes.forEach(box => {
const newSvg = `<svg t="1781771906194" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7961" width="25" height="25"><path d="M712.192 886.784c-143.872 83.968-322.048 84.992-466.944 2.56-144.896-82.944-234.496-236.544-235.52-402.944C9.216 319.488 97.28 164.864 241.152 80.896 385.536-3.072 563.2-4.096 708.096 78.336s234.496 236.544 235.52 402.944c0.512 166.912-87.552 321.536-231.424 405.504z" fill="#9CEF4B" p-id="7962"></path><path d="M655.872 752.64c-117.248 66.56-263.168 67.584-381.44 2.048C156.16 689.152 82.944 567.296 81.92 435.2c-0.512-132.608 71.68-254.976 188.416-322.048 118.272-66.56 263.168-67.584 381.44-2.048s191.488 187.392 192.512 319.488C844.8 563.2 773.12 686.08 655.872 752.64z" fill="#7BC12B" p-id="7963"></path><path d="M730.112 876.032s56.832 1.024 36.864-49.664l-104.96-128.512s-27.136-69.632 41.472-58.368l180.224 194.56s70.144 26.624 58.368-52.224l-218.112-237.568s-1.024-70.144 63.488-51.2l124.928 121.856s62.464-14.336 32.256-62.976L588.8 163.84l-401.92 451.584 344.064 395.264s52.736 20.48 42.496-40.448L466.944 834.56s-12.8-58.368 35.328-38.912l58.88 64.512s41.472 10.24 34.816-38.4l-26.112-38.912s3.072-63.488 55.808-28.672l104.448 121.856z" fill="#4A7F11" p-id="7964"></path><path d="M615.424 912.896l21.504 26.624c9.216 11.264 25.088 12.288 35.328 2.56 10.24-10.24 11.264-27.648 2.048-38.912l-21.504-26.624c-9.216-11.264-25.088-12.288-35.328-2.56s-10.752 27.648-2.048 38.912zM953.856 891.392l6.144 7.168c9.216 11.264 25.088 12.288 35.328 2.56 10.24-10.24 11.264-27.648 2.048-38.912l-6.144-7.168c-9.216-11.264-25.088-12.288-35.328-2.56-9.728 10.24-10.752 27.648-2.048 38.912zM949.76 638.976l21.504 26.624c9.216 11.264 25.088 12.288 35.328 2.56 10.24-10.24 11.264-27.648 2.048-38.912l-21.504-26.624c-9.216-11.264-25.088-12.288-35.328-2.56-10.24 10.752-11.264 27.648-2.048 38.912zM784.896 941.056l21.504 26.624c9.216 11.264 25.088 12.288 35.328 2.56 10.24-10.24 11.264-27.648 2.048-38.912l-21.504-26.624c-9.216-11.264-25.088-12.288-35.328-2.56-10.24 10.752-11.264 27.648-2.048 38.912z" fill="#4A7F11" p-id="7965"></path><path d="M714.24 481.28c-40.448 165.888-208.896 267.264-374.272 226.304-165.888-40.96-267.776-208.896-226.304-374.784s207.872-266.752 373.76-226.304 267.264 208.896 226.816 374.784z" fill="#FFFFFF" p-id="7966"></path><path d="M413.696 723.968c-25.088 0-51.2-3.072-75.776-9.216-41.984-9.728-79.872-28.16-113.664-53.76-32.768-24.576-60.416-54.784-81.408-90.112-21.504-35.328-35.328-73.216-41.984-113.664-6.656-41.984-5.12-83.968 5.632-125.952 8.704-35.328 23.04-68.096 43.52-98.304 19.456-29.184 43.008-54.784 70.656-75.776 27.648-21.504 57.856-37.888 90.624-48.64 33.28-11.776 67.584-17.408 103.424-17.408 25.088 0 51.2 3.072 75.776 9.216 41.984 9.728 79.872 28.16 113.664 53.76 32.768 24.576 60.416 54.784 81.408 90.112 21.504 35.328 35.328 73.216 41.984 113.664 6.656 41.984 5.12 83.968-5.632 125.952-8.704 35.328-23.04 68.608-43.008 98.304-19.456 29.184-43.008 54.784-70.656 75.776-27.648 21.504-57.856 37.888-90.624 48.64-33.792 11.264-68.608 17.408-103.936 17.408z m-0.512-619.008C273.92 104.96 153.6 199.68 120.32 334.848 79.872 497.152 179.2 660.48 341.504 700.928c23.552 6.144 48.128 8.704 72.704 8.704 139.264 0 259.584-94.208 293.376-229.888 19.456-78.336 7.168-159.744-34.816-228.864-41.984-69.12-108.032-118.272-186.88-137.216-23.552-6.144-47.616-8.704-72.704-8.704z" fill="#2D2D2D" p-id="7967"></path><path d="M484.352 113.152L387.584 507.904" fill="#FFFFFF" p-id="7968"></path><path d="M477.184 111.616l13.824 3.072L394.24 509.44l-13.824-3.072 96.768-394.752z" fill="#2D2D2D" p-id="7969"></path><path d="M402.432 412.672l-215.04 201.216" fill="#FFFFFF" p-id="7970"></path><path d="M397.824 407.552l9.216 9.728-215.552 201.216-9.216-9.728 215.552-201.216z" fill="#2D2D2D" p-id="7971"></path><path d="M721.408 418.304l-410.624-22.528" fill="#FFFFFF" p-id="7972"></path><path d="M311.296 389.632l410.624 22.016-0.512 14.336-411.136-22.016 1.024-14.336z" fill="#2D2D2D" p-id="7973"></path><path d="M506.88 697.344L387.072 321.024" fill="#FFFFFF" p-id="7974"></path><path d="M393.728 318.464l119.296 376.832-13.312 4.608-119.296-376.832 13.312-4.608z" fill="#2D2D2D" p-id="7975"></path><path d="M147.456 279.552l360.96 166.4" fill="#FFFFFF" p-id="7976"></path><path d="M150.528 273.408l360.96 166.4-6.144 12.8-360.96-166.4 6.144-12.8z" fill="#2D2D2D" p-id="7977"></path><path d="M238.592 322.048l-17.408-150.016-7.168-1.024c-48.128 40.448-84.48 96.256-100.864 162.304-4.096 16.384-7.168 33.28-8.192 50.688l133.632-61.952z m29.184 218.624l-145.408-27.648c28.16 77.312 86.016 142.336 164.352 176.64 1.024 0-18.944-148.992-18.944-148.992zM378.88 710.656l2.56 4.608c84.48 8.704 166.4-17.408 229.376-69.12l-137.216-52.736L378.88 710.656z m233.984-293.376l77.824 127.488c9.728-19.968 17.408-40.96 23.04-63.488 14.848-59.392 10.752-119.808-7.68-173.568l-93.184 109.568zM360.96 102.4l97.28 113.664 138.752-57.856c-31.744-23.552-69.12-41.984-109.568-51.712-41.984-10.24-84.992-11.264-126.464-4.096z m96.256 434.176l79.872-128.512-97.28-115.2-139.264 56.32 10.752 150.528 145.92 36.864z" fill="#2D2D2D" p-id="7978"></path></svg>`
const existingSvg = box.querySelector('svg');
if (existingSvg) {
const svgWrapper = document.createElement('div');
svgWrapper.className = 'svg-wrapper';
svgWrapper.innerHTML = newSvg;
existingSvg.parentNode.replaceChild(svgWrapper, existingSvg);
} else {
const svgWrapper = document.createElement('div');
svgWrapper.className = 'svg-wrapper';
svgWrapper.innerHTML = newSvg;
box.appendChild(svgWrapper);
}
});
observer.disconnect();
return true;
}
return false;
});
// 配置观察器选项
const config = {
childList: true, // 观察目标子节点的变化,添加或删除
subtree: true // 观察后代节点
};
// 开始观察整个 document
observer.observe(document.body, config);
// bundles-box SVG 插入(同上逻辑)
const observerBundles = new MutationObserver(function(mutations) {
const bundlesBoxes = document.querySelectorAll('.bundles-box');
if (bundlesBoxes.length > 0) {
bundlesBoxes.forEach(box => {
if (box.querySelector('.svg-wrapper')) return; // 已处理过则跳过
const newSvg = `<svg t="1772439140184" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9799" width="24" height="24"><path d="M450.133333 934.4c-8.533333 0-17.066667-2.133333-23.466666-4.266667-61.866667-17.066667-381.866667-85.333333-211.2-514.133333 0 0 29.866667 96 83.2 96 12.8-202.666667 217.6-243.2 128-465.066667 0 0 238.933333 55.466667 268.8 337.066667 0 0 34.133333-89.6 102.4-98.133333 0 0-21.333333 49.066667 0 123.733333 0 0 200.533333 364.8-160 514.133333 0 0-21.333333 8.533333-46.933334 12.8 166.4-168.533333-96-341.333333-96-341.333333 10.666667 89.6-211.2 194.133333-44.8 339.2z" fill="#d81e06" p-id="9800"></path></svg>`;
if (!newSvg) return;
const existingSvg = box.querySelector('svg');
if (existingSvg) {
const svgWrapper = document.createElement('div');
svgWrapper.className = 'svg-wrapper';
svgWrapper.innerHTML = newSvg;
existingSvg.parentNode.replaceChild(svgWrapper, existingSvg);
} else {
const svgWrapper = document.createElement('div');
svgWrapper.className = 'svg-wrapper';
svgWrapper.innerHTML = newSvg;
box.insertBefore(svgWrapper, box.firstChild); // 插入到前面
}
});
observerBundles.disconnect();
}
});
observerBundles.observe(document.body, config);
});
document.addEventListener('DOMContentLoaded', function () {
function updateLogoInvert() {
// 获取 header 内的图标元素,它应该是白色的
const iconElement = document.querySelector('.header .header__icon');
if (!iconElement) {
return;
}
// 获取计算后的实际颜色值
let computedColor = getComputedStyle(iconElement).color;
// 解析RGB值
const rgbMatch = computedColor.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
if (!rgbMatch) {
return;
}
// 检查是否是白色或接近白色
const isLightColor =
Number(rgbMatch[1]) > 200 && Number(rgbMatch[2]) > 200 && Number(rgbMatch[3]) > 200;
// 获取所有 logo 元素
const logos = document.querySelectorAll('.header__heading-logo');
// 根据图标颜色设置 logo 的 invert
logos.forEach((logo) => {
if (isLightColor) {
// 如果图标是浅色/白色,logo保持原样(假设logo本身是白色)
logo.style.filter = 'none';
} else {
// 如果图标是深色,logo需要反转
logo.style.filter = 'invert(1)';
}
});
}
// 初始执行一次
updateLogoInvert();
// 监听可能的颜色变化事件(如滚动、悬停等)
document.addEventListener('scroll', updateLogoInvert);
// 对于 hover 效果
const headerWrapper = document.querySelector('.header');
if (headerWrapper) {
headerWrapper.addEventListener('mouseenter', () => {
updateLogoInvert();
});
headerWrapper.addEventListener('mouseleave', () => {
updateLogoInvert();
});
}
});