rerfactor: 电力pc 导航
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 5s

This commit is contained in:
2025-12-04 15:30:22 +08:00
parent 99d49ee8a2
commit 8311181967
4 changed files with 39 additions and 44 deletions

View File

@@ -125,6 +125,43 @@
</div>
</div>
</header>
<script type="text/javascript">
$(function() {
$('.header-PC #header .navItem>a').each(function(idx, item) {
var _item = $(item);
_item.removeClass('active');
if (_item.attr('href') && compareUrls(location.href, _item.get(0).href)) {
_item.addClass('active').siblings();
}
});
// 比较两个URL是否相等支持只有path的情况并处理有无.html后缀的情况
function compareUrls(url1, url2) {
// 如果输入的是相对路径,添加当前域名
if (!url1.startsWith('http')) {
url1 = window.location.origin + (url1.startsWith('/') ? '' : '/') + url1;
}
if (!url2.startsWith('http')) {
url2 = window.location.origin + (url2.startsWith('/') ? '' : '/') + url2;
}
// 将两个URL转换为URL对象
const urlObj1 = new URL(url1);
const urlObj2 = new URL(url2);
// 获取路径名并移除末尾的斜杠
let path1 = urlObj1.pathname.replace(/\/$/, '');
let path2 = urlObj2.pathname.replace(/\/$/, '');
// 移除.html后缀
path1 = path1.replace(/\.html$/, '');
path2 = path2.replace(/\.html$/, '');
// 比较处理后的路径
return path1 === path2;
}
})
</script>
<script>
$(document).ready(function () {
// 搜索历史记录处理

View File

@@ -1,4 +1,4 @@
{extend name="public/nas_base" /}
{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" href="__CSS__/topic_power_prodline/index.css">
<link rel="stylesheet" href="__CSS__/topic_power_prodline/swiper.css">
@@ -10,13 +10,7 @@
<link rel="stylesheet" href="__CSS__/topic_power_prodline/product_card.css">
<link rel="stylesheet" href="__CSS__/topic_power_prodline/footer.css">
{/block}
{block name="main"}
<!-- <a class="header" href="/">
<div class="header-img">
<img src="__IMAGES__/logo.png" alt="">
</div>
</a> -->
<!-- 轮播核心容器 -->
<div class="swiper-container auto-swiper-container" >
{notempty name="data.focus_image"}