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

@@ -12,43 +12,6 @@ use think\Request;
*/ */
class TopicPowerProdline extends Common class TopicPowerProdline extends Common
{ {
/**
* 重写控制器初始化
*/
public function initialize()
{
// 获取国家/语言列表
$languages = $this->getLanguages();
// 输出国家/语言列表
if (get_platform() == 'mobile') {
View::assign('header_languages', $languages);
}
// 获取当前语言
$current_language = $this->getCurrentLanguage($languages);
if (!empty($current_language)) {
$this->lang_id = $current_language['id'];
}
// 获取产品分类
$categorys = $this->getProductCategory($this->lang_id);
// 输出产品分类
View::assign('header_categorys', $categorys);
// 获取系统配置
$configs = $this->getSysConfig($this->lang_id, ['basic', 'contact', 'media']);
$this->basic_config = $configs['basic'];
// 输出系统配置
View::assign('basic_config', $configs['basic']);
View::assign('contact_config', $configs['contact']);
View::assign('media_config', $configs['media']);
// 获取底部导航
$footer_navigation = $this->getNavigation('NAV_67f60be43df8d', $this->lang_id);
// 输出底部导航
View::assign('footer_navigation', $footer_navigation);
}
/** /**
* 专题 - 电力品线首页 * 专题 - 电力品线首页
*/ */

View File

@@ -125,6 +125,43 @@
</div> </div>
</div> </div>
</header> </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> <script>
$(document).ready(function () { $(document).ready(function () {
// 搜索历史记录处理 // 搜索历史记录处理

View File

@@ -1,4 +1,4 @@
{extend name="public/nas_base" /} {extend name="public/base" /}
{block name="style"} {block name="style"}
<link rel="stylesheet" href="__CSS__/topic_power_prodline/index.css"> <link rel="stylesheet" href="__CSS__/topic_power_prodline/index.css">
<link rel="stylesheet" href="__CSS__/topic_power_prodline/swiper.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/product_card.css">
<link rel="stylesheet" href="__CSS__/topic_power_prodline/footer.css"> <link rel="stylesheet" href="__CSS__/topic_power_prodline/footer.css">
{/block} {/block}
{block name="main"} {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" > <div class="swiper-container auto-swiper-container" >
{notempty name="data.focus_image"} {notempty name="data.focus_image"}

View File

@@ -177,6 +177,7 @@
padding-left: 0; padding-left: 0;
white-space: nowrap; white-space: nowrap;
} }
.header-PC #header .nav2 .navItem > a.active,
.header-PC #header .nav2 .navItem .navItemConten1 li a:hover { .header-PC #header .nav2 .navItem .navItemConten1 li a:hover {
color: #004bfa; color: #004bfa;
} }