function transformSearchUrl(event) {
    event.preventDefault(); // 阻止表单提交

    const keywordInput = document.getElementById("searchInput"); // 确保 id 匹配
    if (!keywordInput) return false;

    let keyword = keywordInput.value.trim(); // 去除前后的空格

    if (!keyword) {
        alert("请输入关键词进行搜索");
        return false;
    }

    // 只允许字母、数字、汉字、韩文和日文字符
    keyword = keyword.replace(/[^a-zA-Z0-9\u4e00-\u9fa5\uac00-\ud7af\u3040-\u30ff\u31f0-\u31ff\u4e00-\u9fff]/g, "");

    if (!keyword) {
        alert("请输入有效的关键词进行搜索");
        return false;
    }

    const domain = window.location.hostname; // 获取当前域名
    const searchUrl = `http://${domain}/search/${encodeURIComponent(keyword)}.html`; // 创建正确的 URL

    // 跳转到正确的 URL
    window.location.href = searchUrl;

    return false; // 防止表单提交
}
    
    


        // 图片懒加载增强
        document.addEventListener("DOMContentLoaded", function() {
            const lazyImages = [].slice.call(document.querySelectorAll("img[loading='lazy']"));
            
            if ("IntersectionObserver" in window) {
                let lazyImageObserver = new IntersectionObserver(function(entries) {
                    entries.forEach(function(entry) {
                        if (entry.isIntersecting) {
                            let lazyImage = entry.target;
                            lazyImage.src = lazyImage.dataset.src;
                            lazyImage.classList.remove("lazy");
                            lazyImageObserver.unobserve(lazyImage);
                        }
                    });
                });

                lazyImages.forEach(function(lazyImage) {
                    lazyImage.dataset.src = lazyImage.src;
                    lazyImage.src = "";
                    lazyImageObserver.observe(lazyImage);
                });
            }
        });
 // 初始化关键词轮播
        new Swiper('.swiper-keywords', {
            slidesPerView: 'auto',
            spaceBetween: 10,
            autoplay: {
                delay: 3000,
                disableOnInteraction: false
            },
            breakpoints: {
                768: {
                    spaceBetween: 15
                }
            }
        });

