diff --git a/.htaccess b/.htaccess index d1a309b..121f556 100644 --- a/.htaccess +++ b/.htaccess @@ -8,4 +8,18 @@ RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] +# BEGIN WordPress +# The directives (lines) between "BEGIN WordPress" and "END WordPress" are +# dynamically generated, and should only be modified via WordPress filters. +# Any changes to the directives between these markers will be overwritten. + +RewriteEngine On +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] +RewriteBase / +RewriteRule ^index\.php$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . /index.php [L] + + # END WordPress \ No newline at end of file diff --git a/wp-content/themes/nenghui-energy-theme-4/assets/css/feature-module.css b/wp-content/themes/nenghui-energy-theme-4/assets/css/feature-module.css index 86fc924..535d586 100644 --- a/wp-content/themes/nenghui-energy-theme-4/assets/css/feature-module.css +++ b/wp-content/themes/nenghui-energy-theme-4/assets/css/feature-module.css @@ -2,7 +2,7 @@ /* feature-module 模块 */ .feature-module { width: 100%; -max-width: 1300px; +max-width: 1320px; margin: 40px auto; overflow: hidden; background-color: #fff; diff --git a/wp-content/themes/nenghui-energy-theme-4/assets/css/index.css b/wp-content/themes/nenghui-energy-theme-4/assets/css/index.css index e7ae19f..7c1b8bf 100644 --- a/wp-content/themes/nenghui-energy-theme-4/assets/css/index.css +++ b/wp-content/themes/nenghui-energy-theme-4/assets/css/index.css @@ -4,7 +4,7 @@ margin: 0; padding: 0; box-sizing: border-box; - font-family: "calibri","PingFang SC", Arial, sans-serif; + /* font-family: "calibri","PingFang SC", Arial, sans-serif; */ } /* 链接样式 */ @@ -800,15 +800,15 @@ img { } .footer-container { - max-width: 1300px; + max-width: 1320px; margin: 0 auto; padding: 0 20px; } .footer-main { display: grid; - grid-template-columns: 1fr 3fr 1fr; - gap: 0; + grid-template-columns: 1fr auto; + gap: 10px; margin-bottom: 40px; } @@ -834,6 +834,65 @@ img { display: flex; gap: 15px; } +/* 社交图标基础样式 (适配浅色背景) */ +.social-btn { + position: relative; + width: 42px; + height: 42px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 50%; + + /* 默认状态:深色图标,浅色背景 */ + background: #ffffff; /* 纯白背景 */ + border: 1px solid rgba(13, 27, 23, 0.1); /* 极淡的深色边框 */ + color: #0d1b17; /* 深绿色/黑色图标,确保可见性 */ + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); /* 轻微阴影增加层次感 */ + + transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); + cursor: pointer; + overflow: hidden; +} + +/* --- 悬停通用效果 --- */ +.social-btn:hover { + transform: translateY(-4px); /* 上浮 */ + color: #ffffff; /* 图标反白 */ + border-color: transparent; +} + +/* --- 品牌色定义 (悬停时触发) --- */ + +/* LinkedIn Blue */ +.social-btn.linkedin:hover { + background: #0077b5; + box-shadow: 0 10px 20px -5px rgba(0, 119, 181, 0.4); +} + +/* Facebook Blue */ +.social-btn.facebook:hover { + background: #1877f2; + box-shadow: 0 10px 20px -5px rgba(24, 119, 242, 0.4); +} + +/* X (Twitter) Black */ +.social-btn.twitter:hover { + background: #000000; + box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.3); +} + +/* YouTube Red */ +.social-btn.youtube:hover { + background: #ff0000; + box-shadow: 0 10px 20px -5px rgba(255, 0, 0, 0.4); +} + +/* --- 点击反馈 --- */ +.social-btn:active { + transform: translateY(-1px); + box-shadow: 0 2px 5px rgba(0,0,0,0.1); +} .social-link { display: flex; diff --git a/wp-content/themes/nenghui-energy-theme-4/assets/js/index.js b/wp-content/themes/nenghui-energy-theme-4/assets/js/index.js index edab99d..3a5101f 100644 --- a/wp-content/themes/nenghui-energy-theme-4/assets/js/index.js +++ b/wp-content/themes/nenghui-energy-theme-4/assets/js/index.js @@ -1,6 +1,120 @@ // 这是自定义JS文件,用于覆盖主题默认JS文件 + /** + * AdvancedImageLoader + * 通用图片加载管理器:支持懒加载、预加载、骨架屏控制 + */ +class AdvancedImageLoader { + constructor(options = {}) { + this.options = Object.assign({ + rootMargin: '200px 0px', // 提前 200px 开始加载 + threshold: 0.01, // 只要露出 1% 就加载 + selector: '.lazy-target',// 需要懒加载的目标选择器 + skeletonClass: 'skeleton-pulse', // 骨架屏动画类名 + loadedClass: 'loaded', // 加载完成后的 CSS 类名 + }, options); + + this.observer = null; + this.init(); + } + + init() { + if ('IntersectionObserver' in window) { + this.observer = new IntersectionObserver((entries, observer) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + this.loadImage(entry.target); + observer.unobserve(entry.target); + } + }); + }, { + rootMargin: this.options.rootMargin, + threshold: this.options.threshold + }); + } + this.scan(); + } + + /** + * 扫描 DOM,寻找未加载的图片并加入观察队列 + * 注意:在动态渲染(如搜索、翻页)后必须调用此方法 + */ + scan() { + const elements = document.querySelectorAll(`${this.options.selector}:not(.${this.options.loadedClass})`); + elements.forEach(el => { + // 如果浏览器不支持 Observer,直接加载 + if (!this.observer) { + this.loadImage(el); + } else { + this.observer.observe(el); + } + }); + } + + /** + * 核心加载逻辑 + * @param {HTMLElement} el 目标 DOM 元素 + */ + loadImage(el) { + const bgSrc = el.getAttribute('data-bg'); + const imgSrc = el.getAttribute('data-src'); + // 寻找外层包裹的骨架屏容器(如果有) + const skeleton = el.closest('.skeleton-wrapper'); + + if (!bgSrc && !imgSrc) return; + + // 1. 创建内存对象进行预加载 (Preload) + const loader = new Image(); + + loader.onload = () => { + // 2. 图片下载完毕,更新 DOM + if (bgSrc) { + el.style.backgroundImage = `url("${bgSrc}")`; + } + if (imgSrc) { + el.setAttribute('src', imgSrc); + } + + // 3. 触发 CSS 动画 (Fade-in) + // 使用 requestAnimationFrame 确保样式重绘顺滑 + requestAnimationFrame(() => { + el.classList.add(this.options.loadedClass); + }); + + // 4. 关闭骨架屏动画 + if (skeleton) { + skeleton.classList.remove(this.options.skeletonClass); + // 可选:加载完成后移除背景色,或者保留作为底色 + // skeleton.style.backgroundColor = 'transparent'; + } + }; + + loader.onerror = () => { + console.warn('Image load failed:', bgSrc || imgSrc); + // 即使失败也移除动画,避免一直闪烁 + if (skeleton) skeleton.classList.remove(this.options.skeletonClass); + }; + + // 开始下载 + loader.src = bgSrc || imgSrc; + } + + /** + * 手动强制预加载一组图片(不等待进入视口) + * 适用于:轮播图的首屏图片、模态框弹出前的图片 + * @param {Array} urls 图片链接数组 + */ + static preloadBatch(urls) { + urls.forEach(url => { + const img = new Image(); + img.src = url; + }); + } +} + document.addEventListener('DOMContentLoaded', function() { + // 加载图片,支持懒加载、预加载、骨架屏控制 + window.ImageLoader = new AdvancedImageLoader(); // 菜单切换 const menuToggle = document.querySelector('.menu-toggle'); const navMenu = document.querySelector('.nav-menu'); @@ -122,67 +236,67 @@ document.addEventListener('DOMContentLoaded', function() { let lastScroll = 0; const nav = document.querySelector('.main-nav'); - window.addEventListener('scroll', function() { - const currentScroll = window.pageYOffset; + // window.addEventListener('scroll', function() { + // const currentScroll = window.pageYOffset; - // 到顶部时显示导航栏并清除背景和阴影 - if (currentScroll <= 0) { - nav.classList.remove('scrolled'); - nav.style.transform = 'translateY(0)'; - nav.style.backgroundColor = ''; - nav.style.boxShadow = ''; - // 设置主菜单项颜色为白色 - const menuLinks = nav.querySelectorAll('.menu-items > li > a'); - menuLinks.forEach(link => { - link.style.color = '#333'; - }); - // 确保下拉菜单项保持黑色 - const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); - subMenuLinks.forEach(link => { - link.style.color = '#333'; - }); - } else if (currentScroll > 80) { - // 滚动超过80px时添加背景和阴影 - nav.classList.add('scrolled'); - nav.style.backgroundColor = '#fff'; - nav.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 1)'; - // 设置主菜单项颜色为黑色 - const menuLinks = nav.querySelectorAll('.menu-items > li > a'); - menuLinks.forEach(link => { - link.style.color = '#000'; - }); - // 确保下拉菜单项保持黑色 - const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); - subMenuLinks.forEach(link => { - link.style.color = '#333'; - }); - if (currentScroll > lastScroll) { - // 向下滚动时显示导航栏 - nav.style.transform = 'translateY(0)'; - } else { - // 向上滚动时隐藏导航栏 - nav.style.transform = 'translateY(-100%)'; - } - } else { - // 滚动在0-80px之间时清除背景和阴影 - nav.classList.remove('scrolled'); - nav.style.backgroundColor = ''; - nav.style.boxShadow = ''; - nav.style.transform = 'translateY(0)'; - // 设置主菜单项颜色为白色 - const menuLinks = nav.querySelectorAll('.menu-items > li > a'); - menuLinks.forEach(link => { - link.style.color = '#333'; - }); - // 确保下拉菜单项保持黑色 - const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); - subMenuLinks.forEach(link => { - link.style.color = '#333'; - }); - } + // // 到顶部时显示导航栏并清除背景和阴影 + // if (currentScroll <= 0) { + // nav.classList.remove('scrolled'); + // nav.style.transform = 'translateY(0)'; + // nav.style.backgroundColor = ''; + // nav.style.boxShadow = ''; + // // 设置主菜单项颜色为白色 + // const menuLinks = nav.querySelectorAll('.menu-items > li > a'); + // menuLinks.forEach(link => { + // link.style.color = '#333'; + // }); + // // 确保下拉菜单项保持黑色 + // const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); + // subMenuLinks.forEach(link => { + // link.style.color = '#333'; + // }); + // } else if (currentScroll > 80) { + // // 滚动超过80px时添加背景和阴影 + // nav.classList.add('scrolled'); + // nav.style.backgroundColor = '#fff'; + // nav.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 1)'; + // // 设置主菜单项颜色为黑色 + // const menuLinks = nav.querySelectorAll('.menu-items > li > a'); + // menuLinks.forEach(link => { + // link.style.color = '#000'; + // }); + // // 确保下拉菜单项保持黑色 + // const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); + // subMenuLinks.forEach(link => { + // link.style.color = '#333'; + // }); + // if (currentScroll > lastScroll) { + // // 向下滚动时显示导航栏 + // nav.style.transform = 'translateY(0)'; + // } else { + // // 向上滚动时隐藏导航栏 + // nav.style.transform = 'translateY(-100%)'; + // } + // } else { + // // 滚动在0-80px之间时清除背景和阴影 + // nav.classList.remove('scrolled'); + // nav.style.backgroundColor = ''; + // nav.style.boxShadow = ''; + // nav.style.transform = 'translateY(0)'; + // // 设置主菜单项颜色为白色 + // const menuLinks = nav.querySelectorAll('.menu-items > li > a'); + // menuLinks.forEach(link => { + // link.style.color = '#333'; + // }); + // // 确保下拉菜单项保持黑色 + // const subMenuLinks = nav.querySelectorAll('.sub-menu li a'); + // subMenuLinks.forEach(link => { + // link.style.color = '#333'; + // }); + // } - lastScroll = currentScroll; - }); + // lastScroll = currentScroll; + // }); // 鼠标移入移出导航栏效果 nav.addEventListener('mouseenter', function() { diff --git a/wp-content/themes/nenghui-energy-theme-4/footer.php b/wp-content/themes/nenghui-energy-theme-4/footer.php index 61a4904..e08ebae 100644 --- a/wp-content/themes/nenghui-energy-theme-4/footer.php +++ b/wp-content/themes/nenghui-energy-theme-4/footer.php @@ -5,73 +5,84 @@