首页违规举报

违规举报 2026-08-04 3354

网站违规举报

此框自动填充,无需手动修改
$(document).ready(function(){ // 拦截左侧.pjax-menu菜单,仅局部刷新#pjax-container $("#goto").off("click").on("click",".pjax-menu",function(e){ e.preventDefault(); const targetUrl = $(this).attr('href'); $.pjax({ url: targetUrl, container:'#pjax-container', fragment:"#pjax-container", timeout:8000, scrollTo:false, // 保留滚动位置,不自动跳顶部 cache:false, // 关闭缓存,实时更新SEO与页面内容 push:true }) }); // 切换淡入淡出动画 $(document).on('pjax:send',function(){ $('#pjax-container').fadeTo(300,0.5); }) $(document).on('pjax:complete',function(){ $('#pjax-container').fadeTo(300,1); }) // PJAX加载完成:同步SEO + 重载所有主题JS组件(关键) $(document).on("pjax:complete", function(event, xhr, options, response){ // ========= 1. 同步全部头部SEO标签(兼容百度寒武纪) ========= const fullPage = $(''+response+''); // 更新页面标题 document.title = fullPage.find('title').text(); // 替换关键词、描述、robots $('meta[name="keywords"]').attr('content', fullPage.find('meta[name="keywords"]').attr('content')); $('meta[name="description"]').attr('content', fullPage.find('meta[name="description"]').attr('content')); $('meta[name="robots"]').attr('content', fullPage.find('meta[name="robots"]').attr('content')); // 规范链接canonical $('link[rel="canonical"]').attr('href', fullPage.find('link[rel="canonical"]').attr('href')); // OG社交标签、Twitter标签批量更新 $('meta[property^="og:"]').each(function(){ let p = $(this).attr('property'); $(this).attr('content', fullPage.find(`meta[property="${p}"]`).attr('content')); }) $('meta[name^="twitter:"]').each(function(){ let n = $(this).attr('name'); $(this).attr('content', fullPage.find(`meta[name="${n}"]`).attr('content')); }) // 清空旧结构化数据,重新注入百度寒武纪+Schema脚本 $('script[type="application/ld+json"]').remove(); fullPage.find('script[type="application/ld+json"]').each(function(){ $('head').append($(this).clone()); }); // ========= 2. 分类菜单激活高亮 ========= let now_cid = getUrlParam('cid'); $(".pjax-menu").removeClass("active"); $(`.pjax-menu[href*="cid=${now_cid}"]`).addClass("active"); // ========= 3. 重载主题内置插件 ========= // tooltip悬浮提示 $('.autoleft').tooltip({ align: 'autoLeft', fade: {duration: 200, opacity: 0.8} }); // 侧边sticky固定跟随 jQuery('.sticky').positionSticky({offsetTop: 78}); // 首页轮播Swiper(仅首页第一页实例化) if(location.search.indexOf('page=1') !== -1 || location.search === ""){ if(window.Swiper){ new Swiper('.swiper-container', { pagination: '.swiper-pagination', nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', centeredSlides: true, autoplay: 3500, slidesPerView: 1, paginationClickable: true, autoplayDisableOnInteraction: false, spaceBetween: 0, loop: true }); } } // 同步暗黑/明亮模式Cookie状态 refreshNightMode(); }); // PJAX加载失败兜底:整页跳转防止空白 $(document).on('pjax:error', function (e, xhr) { window.location.href = xhr.responseURL; }) // 获取URL参数工具函数(保留原有逻辑) function getUrlParam(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r!=null)return decodeURIComponent(r[2]); return null; } // 重载夜间模式状态 function refreshNightMode(){ var night = document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$)|^.*$/, "$1") || '0'; if(night == '0') document.body.classList.remove('night'); else document.body.classList.add('night'); } }) // 夜间模式切换函数(全局,不受PJAX影响,不修改原有代码) function switchNightMode(){ var night = document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$/, "$1") || '0'; if(night == '0'){ document.body.classList.add('night'); document.cookie = "night=1;path=/" }else{ document.body.classList.remove('night'); document.cookie = "night=0;path=/" } }