OneNav V5.56 导航主题
1:在父主题(不推荐)或子主题(推荐)中的 functions.php文件中添加下方引用代码,添加在文件最下方即可;
// 引用 func.php 文件
require get_theme_file_path('/Shortcut-Menu.php');
2:将文件上传至你的functions.php同级目录(也可以上传至别的路径,记得调整functions.php引用文件路径)
也可以直接复制下方Shortcut-Menu.php内容 ↓ ↓ ↓
<?php
/**
* 快捷菜单
*/
if (!defined('ABSPATH')) exit; // 防止直接访问
// 注册自定义样式
add_action('wp_enqueue_scripts', 'custom_menu_enqueue_styles');
// 添加自定义内容到头部
add_action('wp_head', 'add_custom_navigation_menu');
/**
* 注册并加载菜单样式
*/
function custom_menu_enqueue_styles() {
// 仅在需要时加载样式
if (!is_admin()) {
// 加载所有CSS样式
wp_register_style('custom-menu-styles', false);
wp_enqueue_style('custom-menu-styles');
$custom_css = ".topgj_r{display:flex;align-items:center;height:100%;margin-right:15px}.topgj_r .menu-item{position:relative;display:flex;align-items:center;height:100%}.topgj_r .menu-item>a{display:flex;align-items:center;padding:8px;font-size:13px;font-weight:500;color:var(--body-color);text-decoration:none;transition:all .3s ease}.topgj_r .menu-item>a::after{display:none}.topgj_r .menu-item:hover>a{color:var(--theme-color)}.sub-menu-z{position:absolute;top:100%;right:50%;z-index:1000;min-width:90px;padding:8px 0;margin:0;background:var(--main-bg-color);border-radius:8px;box-shadow:0 3px 12px rgba(0,0,0,.12);list-style-type:none;opacity:0;visibility:hidden;transform:translateX(50%);transform-origin:top center;transition:all .25s cubic-bezier(.3,0,.3,1)}.topgj_r .menu-item:hover .sub-menu-z{opacity:1;visibility:visible;transform:translateX(50%) translateY(0)}.sub-menu-z .menu-item-z{margin:0;padding:0;list-style:none;white-space:nowrap;text-align:center}.sub-menu-z .menu-item-z a{display:flex;align-items:center;justify-content:center;width:100%;min-height:36px;padding:6px 12px;margin:0;font-size:13px;color:#666;text-decoration:none;text-align:center;transition:all .2s ease}.sub-menu-z .menu-item-z span{display:block;width:100%;text-align:center;line-height:1.4}.sub-menu-z .menu-item-z a:hover{background:rgba(230,232,234,.8);color:#f1404b;border-radius:8px}.quick-tools-container{margin-top:1rem;padding:15px;background:var(--muted-bg-a-color);border-radius:var(--theme-border-radius);transition:background-color .3s ease}.quick-tools-title{display:flex;align-items:center;padding:10px 0;margin-bottom:10px;font-size:14px;font-weight:600;color:var(--main-color);border-bottom:1px solid var(--muted-bg-color)}.quick-tools-title i{margin-right:8px;font-size:16px;color:var(--theme-color)}.quick-tool-category{margin-bottom:8px}.quick-tool-category .category-title{display:flex;justify-content:space-between;align-items:center;padding:8px 0;font-size:13px;font-weight:500;color:var(--main-color);cursor:pointer;transition:color .3s ease}.quick-tool-category .category-title:hover{color:var(--theme-color)}.quick-tool-category .category-title i{font-size:12px;transition:transform .3s ease}.category-content{max-height:0;overflow:hidden;transition:max-height .4s ease}.category-content.show{max-height:300px}.tool-link{display:inline-block;padding:4px 8px;margin:2px;font-size:12px;color:var(--main-color);background:var(--main-bg-color);border:1px solid transparent;border-radius:var(--theme-border-radius-sm);text-decoration:none;transition:all .3s ease}.tool-link:hover{color:#fff;background:var(--theme-color);text-decoration:none;transform:translateY(-1px);box-shadow:0 2px 4px rgba(0,0,0,.1)}
.desktop-drawer{position:fixed;top:0;right:-240px;width:240px;height:100vh;z-index:100;padding-top:70px;background:var(--main-bg-color);box-shadow:-2px 0 20px var(--main-shadow);border-radius:var(--theme-border-radius) 0 0 var(--theme-border-radius);display:flex;flex-direction:column;overflow:hidden;transition:right .3s cubic-bezier(.3,0,.3,1)}.desktop-drawer.show{right:0}.desktop-drawer-overlay{position:fixed;top:0;left:0;width:100%;height:100vh;z-index:99;background:rgba(0,0,0,.5);backdrop-filter:blur(4px);opacity:0;visibility:hidden;transition:all .3s ease}.desktop-drawer-overlay.show{opacity:1;visibility:visible}.desktop-drawer-header{display:flex;align-items:center;justify-content:flex-start;position:relative;padding:12px 15px;min-height:45px;font-size:14px;font-weight:600;color:var(--main-color);backdrop-filter:saturate(2) blur(15px);-webkit-backdrop-filter:saturate(2) blur(15px);border-bottom:1px solid var(--muted-bg-a-color);flex-shrink:0;transition:background-color .3s ease}
.desktop-drawer-menu{flex:1;padding:0;margin:0;list-style:none;overflow-y:auto}.desktop-drawer-menu .menu-category{margin-bottom:4px;border-bottom:none}.desktop-drawer-menu .category-toggle{opacity:.7;transition:transform .2s ease}.desktop-drawer-menu .category-toggle i{font-size:12px}.desktop-drawer-menu .category-title{position:relative;display:flex;align-items:center;justify-content:space-between;margin:3px 6px;padding:10px 15px;font-size:12px;font-weight:500;color:var(--main-color);background:linear-gradient(135deg,var(--muted-bg-color-l) 0%,var(--muted-bg-color) 100%);border-radius:var(--theme-border-radius-sm);cursor:pointer;transition:all .3s ease}.desktop-drawer-menu .category-title:hover{color:var(--theme-color);background:var(--theme-color-bg);transform:translateX(2px)}.desktop-drawer-menu .category-items{max-height:0;margin:0 6px;background:var(--main-bg-color);border-radius:var(--theme-border-radius-sm);overflow:hidden;transition:max-height .3s ease}.desktop-drawer-menu .category-items.show{max-height:350px}.desktop-drawer-menu .category-items a{position:relative;display:block;margin:1px 3px;padding:6px 15px;font-size:11px;color:var(--main-color);text-decoration:none;border-radius:var(--theme-border-radius-sm);border-bottom:1px solid var(--muted-bg-a-color);transition:all .2s ease}.desktop-drawer-menu .category-items a:hover{color:var(--theme-color);background:var(--theme-color-bg);border-color:transparent;transform:translateX(2px)}.desktop-drawer-menu .category-items a:last-child{border-bottom:none}
.io-black-mode .sub-menu-z{background:#2c2e2f}.io-black-mode .sub-menu-z .menu-item-z a{min-height:36px;color:#c6c9cf}.io-black-mode .sub-menu-z .menu-item-z a:hover{background:rgba(255,255,255,.08);color:var(--theme-color)}
.header-nav .nav-container{margin-left:0}.navbar-menu .menu-item i{margin-right:5px}.nav-container{display:flex;align-items:center;justify-content:flex-end;flex-shrink:0}.nav-container .topgj_r{display:flex;align-items:center;margin-right:0;flex-shrink:0}.header-nav .nav-container{margin-left:0}.navbar-menu .menu-item i{margin-right:5px}.nav-container{display:flex;align-items:center;justify-content:flex-end;flex-shrink:0}.nav-container .topgj_r{display:flex;align-items:center;margin-right:0;flex-shrink:0}
.header-nav .menu-btn{position:relative;width:34px;height:34px;margin-left:5px;border-radius:50%;cursor:pointer;transition:opacity .16s cubic-bezier(.33,1,.68,1)}.header-nav .menu-btn .menu-bar{position:absolute;display:block;inset:0 8px 0 auto;margin:auto;width:18px;height:2px;background-color:var(--main-color);border-radius:2px;transition:all .46s cubic-bezier(.215,.61,.355,1)}.header-nav .menu-btn .menu-bar:nth-child(1){top:-14px}.header-nav .menu-btn .menu-bar:nth-child(2){top:0}.header-nav .menu-btn .menu-bar:nth-child(3){top:14px;width:12px}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(1){width:20px;top:0;right:7px;transform:rotate(45deg)}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(2){width:0;opacity:0}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(3){width:20px;top:0;right:7px;transform:rotate(-45deg)}
.drawer-button-container{display:flex;align-items:center;margin-left:5px;flex-shrink:0}.desktop-drawer-toggle{position:relative;width:34px;height:34px;z-index:101;border-radius:50%;cursor:pointer;transition:opacity .16s cubic-bezier(.33,1,.68,1)}.desktop-drawer-toggle .menu-bar{position:absolute;display:block;inset:0 8px 0 auto;margin:auto;width:18px;height:2px;background-color:var(--main-color);border-radius:2px;transition:all .46s cubic-bezier(.215,.61,.355,1)}.desktop-drawer-toggle .menu-bar:nth-child(1){top:-14px}.desktop-drawer-toggle .menu-bar:nth-child(2){top:0}.desktop-drawer-toggle .menu-bar:nth-child(3){top:14px;width:12px}.desktop-drawer-toggle[aria-expanded='true'] .menu-bar:nth-child(1){width:20px;top:0;right:7px;transform:rotate(45deg)}.desktop-drawer-toggle[aria-expanded='true'] .menu-bar:nth-child(2){width:0;opacity:0}.desktop-drawer-toggle[aria-expanded='true'] .menu-bar:nth-child(3){width:20px;top:0;right:7px;transform:rotate(-45deg)}
@media (min-width:768px) and (max-width:1200px){.header-nav .menu-btn.d-md-none{display:none!important}.header-nav .menu-btn{display:none!important}}@media (max-width:767px){.header-nav .menu-btn.d-md-none{display:block!important}.header-nav .menu-btn{margin-left:0!important}.header-nav .menu-btn .menu-bar{inset:0 auto 0 8px!important}.header-nav .menu-btn .menu-bar:nth-child(1){top:-14px!important}.header-nav .menu-btn .menu-bar:nth-child(2){top:0!important}.header-nav .menu-btn .menu-bar:nth-child(3){top:14px!important;width:12px!important}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(1){width:20px!important;top:0!important;left:7px!important;right:auto!important;transform:rotate(45deg)}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(2){width:0!important;opacity:0}.header-nav .menu-btn[aria-expanded='true'] .menu-bar:nth-child(3){width:20px!important;top:0!important;left:7px!important;right:auto!important;transform:rotate(-45deg)}}@media (min-width:1201px){.header-nav .menu-btn.d-md-none{display:none!important}.header-nav .menu-btn{display:none!important}}@media (min-width:1201px){.topgj_r{display:flex!important}.drawer-button-container{display:none}}@media (max-width:1200px){.topgj_r{display:none!important}.drawer-button-container{display:flex!important;flex-shrink:0;margin-left:5px}}@media (max-width:767px){.drawer-button-container{display:none!important}}";
wp_add_inline_style('custom-menu-styles', $custom_css);
}
}
function add_custom_navigation_menu() {
// 仅在前端且非管理员页面加载
if (is_admin()) return;
ob_start(); // 开启输出缓冲
?>
<!--wp-compress-html no compression-->
<script>(()=>{'use strict';
// 菜单数据配置
const menuData = [
{
title: "传文件",
items: [
{ name: "文叔叔", url: "https://www.wenshushu.cn/" },
{ name: "轻松传", url: "https://easychuan.cn/" },
{ name: "PP直连", url: "https://www.ppzhilian.com/" },
{ name: "奶牛快传", url: "https://cowtransfer.com/" },
{ name: "微信助手", url: "https://filehelper.weixin.qq.com/" }
]
},
{
title: "工具",
items: [
{ name: "抠图", url: "https://www.remove.bg/zh" },
{ name: "PDF工具", url: "https://www.ilovepdf.com/zh-cn" },
{ name: "图片工具", url: "https://www.iloveimg.com/zh-cn" },
{ name: "格式转换", url: "https://www.aconvert.com/cn/" }
]
},
{
title: "网盘",
items: [
{ name: "百度网盘", url: "https://pan.baidu.com/" },
{ name: "阿里云盘", url: "https://www.aliyundrive.com/" },
{ name: "腾讯微云", url: "https://www.weiyun.com/" },
{ name: "文叔叔", url: "https://www.wenshushu.cn/" },
{ name: "蓝奏云", url: "https://www.lanzou.com/" }
]
},
{
title: "翻译",
items: [
{ name: "百度翻译", url: "https://fanyi.baidu.com/" },
{ name: "谷歌翻译", url: "https://translate.google.com/" },
{ name: "有道翻译", url: "https://fanyi.youdao.com/" },
{ name: "DeepL翻译", url: "https://www.deepl.com/translator" }
]
},
{
title: "地图",
items: [
{ name: "百度地图", url: "https://map.baidu.com/" },
{ name: "高德地图", url: "https://ditu.amap.com/" },
{ name: "腾讯地图", url: "https://map.qq.com/" }
]
},
{
title: "识图",
items: [
{ name: "百度识图", url: "https://graph.baidu.com/pcpage/index?tpl_from=pc" },
{ name: "谷歌识图", url: "https://images.google.com/" },
{ name: "360识图", url: "https://image.so.com/" }
]
},
{
title: "邮箱",
items: [
{ name: "QQ邮箱", url: "https://mail.qq.com/" },
{ name: "126邮箱", url: "https://mail.126.com/" },
{ name: "163邮箱", url: "https://mail.163.com/" },
{ name: "189邮箱", url: "https://webmail30.189.cn/" },
{ name: "139邮箱", url: "https://mail.10086.cn/" },
{ name: "阿里邮箱", url: "https://mail.aliyun.com/" },
{ name: "网易邮箱", url: "https://mail.yeah.net/" },
{ name: "搜狐邮箱", url: "https://mail.sohu.com/" },
{ name: "新浪邮箱", url: "https://mail.sina.com.cn/" },
{ name: "微软邮箱", url: "https://outlook.live.com/" },
{ name: "谷歌邮箱", url: "https://mail.google.com/" }
]
}
];
const m=menuData;const D={c:new Map(),get(s,x=document){const k=`${s}::${x===document?'d':'x'}`;let e=this.c.get(k);(!e||!document.contains(e))&&(e=x.querySelector(s))&&this.c.set(k,e);return e},getAll(s,x=document){const k=`a::${s}::${x===document?'d':'x'}`;let es=this.c.get(k);if(!es){es=[...x.querySelectorAll(s)];this.c.set(k,es)}return es},inv(s){[...this.c.keys()].filter(k=>k.includes(s)).forEach(k=>this.c.delete(k))},clr(){this.c.clear()}};const esc=t=>t?.replace?.(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))??'';const E={l:new Map(),d:new Map(),add(e,v,f,o={}){if(!e||!f)return;const k=`${Date.now()}_${Math.random()}`;e.addEventListener(v,f,o);this.l.set(k,{e,v,f,o});return k},del(k){const l=this.l.get(k);l&&(l.e.removeEventListener(l.v,l.f,l.o),this.l.delete(k))},deleg(p,v,s,h){const k=`${p.id||'n'}_${v}_${s}`;if(this.d.has(k))return this.d.get(k);const dh=e=>{const t=e.target.closest(s);t&&p.contains(t)&&h.call(t,e)};const dk=this.add(p,v,dh);this.d.set(k,dk);return dk},deb(f,w,i=0){let t;return function(...a){const l=()=>{t=null;!i&&f.apply(this,a)};const n=i&&!t;clearTimeout(t);t=setTimeout(l,w);n&&f.apply(this,a)}},thr(f,w){let t,p=0;return function(...a){const n=Date.now(),r=w-(n-p);if(r<=0||r>w){t&&(clearTimeout(t),t=null);p=n;f.apply(this,a)}else if(!t){t=setTimeout(()=>{p=Date.now();t=null;f.apply(this,a)},r)}}},clr(){this.l.clear();this.d.clear()}};const A={tog(e,c='show',i=null){if(!e)return!1;e.style.willChange='transform,opacity';const a=e.classList.contains(c);a?(e.classList.remove(c),i&&(i.style.transform='rotate(0deg)')):(e.classList.add(c),i&&(i.style.transform='rotate(180deg)'));setTimeout(()=>e.style.willChange='auto',300);return!a},scr(e,o={}){e.scrollIntoView({behavior:'smooth',block:'start',inline:'nearest',...o})},bat(u){return new Promise(r=>requestAnimationFrame(()=>{u.forEach(up=>up());r()}))}};const B={c:new Map(),itm(it,i){const k=`i_${i}_${it.title}`;if(this.c.has(k))return this.c.get(k);const si=it.items.map(s=>`<li class="menu-item-z"><a target="_blank" rel="nofollow noopener" href="${esc(s.url)}"><span>${esc(s.name)}</span></a></li>`).join('');const h=`<li class="menu-item menu-item-type-post_type menu-item-object-page" data-menu-id="${i}"><a rel="noopener" href="javascript:void(0)" aria-haspopup="true"><span>${esc(it.title)}</span></a><ul class="sub-menu-z">${si}</ul></li>`;this.c.set(k,h);return h},mob(c,i){const ce=document.createElement('div');ce.className='quick-tool-category';const ct=document.createElement('div');ct.className='category-title';ct.innerHTML=`<span>${esc(c.title)}</span><i class="iconfont icon-arrow-b"></i>`;ct.setAttribute('data-category',i);const cc=document.createElement('div');cc.className='category-content';cc.id=`mobile-category-${i}`;const f=document.createDocumentFragment();c.items.forEach(it=>{const l=document.createElement('a');Object.assign(l,{href:it.url,target:'_blank',rel:'nofollow noopener',className:'tool-link',textContent:it.name});f.appendChild(l)});cc.appendChild(f);ce.append(ct,cc);return ce},drw(){const k='d';if(this.c.has(k))return this.c.get(k);const mi=m.map((it,i)=>{const ci=`desktop-category-${i}`;const ih=it.items.map(s=>`<a href="${esc(s.url)}" target="_blank" rel="nofollow noopener">${esc(s.name)}</a>`).join('');return`<li class="menu-category"><div class="category-title" data-target="${ci}"><span>${esc(it.title)}</span><div class="category-toggle"><i class="iconfont icon-arrow-b"></i></div></div><div class="category-items" id="${ci}">${ih}</div></li>`}).join('');const h=`<div class="desktop-drawer-header"><div class="drawer-title">快捷工具</div></div><ul class="desktop-drawer-menu">${mi}</ul>`;this.c.set(k,h);return h},clr(){this.c.clear()}};const MC={tog(i){const co=document.getElementById(`mobile-category-${i}`);const ar=document.querySelector(`[data-category="${i}"] .icon-arrow-b`);if(!co||!ar)return;const op=co.classList.contains('show');document.querySelectorAll('.category-content.show').forEach(oc=>{if(oc!==co){oc.classList.remove('show');const oi=oc.id.replace('mobile-category-','');const oa=document.querySelector(`[data-category="${oi}"] .icon-arrow-b`);oa&&(oa.style.transform='rotate(0deg)')}});op?(co.classList.remove('show'),ar.style.transform='rotate(0deg)'):(co.classList.add('show'),ar.style.transform='rotate(180deg)')}};const DC={e:{t:null,d:null,o:null},ini(){Object.assign(this.e,{t:document.getElementById('desktop-drawer-toggle'),d:document.getElementById('desktop-drawer'),o:document.getElementById('desktop-drawer-overlay')});const{t,d,o}=this.e;if(!t||!d||!o)return;this.bind()},bind(){const{t,o}=this.e;E.add(t,'click',e=>{e.preventDefault();e.stopPropagation();this.tog()});E.add(o,'click',()=>this.cls());E.add(document,'keydown',e=>{e.key==='Escape'&&this.isOp()&&this.cls()});this.bindCat()},bindCat(){this.e.d.querySelectorAll('.category-title').forEach(ti=>{E.add(ti,'click',()=>{const tid=ti.getAttribute('data-target');const co=document.getElementById(tid);const to=ti.querySelector('.category-toggle i');if(co&&to){const op=co.classList.contains('show');this.e.d.querySelectorAll('.category-items.show').forEach(oc=>{if(oc!==co){oc.classList.remove('show');const oid=oc.id;const oti=this.e.d.querySelector(`[data-target="${oid}"]`);const oto=oti?.querySelector('.category-toggle i');oto&&(oto.style.transform='rotate(0deg)')}});op?(co.classList.remove('show'),to.style.transform='rotate(0deg)'):(co.classList.add('show'),to.style.transform='rotate(180deg)')}})})},opn(){const{d,o,t}=this.e;d.classList.add('show');o.classList.add('show');t.setAttribute('aria-expanded','true');document.body.style.overflow='hidden'},cls(){const{d,o,t}=this.e;d.classList.remove('show');o.classList.remove('show');t.setAttribute('aria-expanded','false');document.body.style.overflow=''},tog(){this.isOp()?this.cls():this.opn()},isOp(){return this.e.t.getAttribute('aria-expanded')==='true'}};const MI={ini:{d:0,m:0,dr:0},ini(){try{this.iniVp();this.bindVp()}catch(e){console.error('菜单初始化失败:',e)}},iniVp(){const w=innerWidth;w>=1201?this.creDsk():w>=768?this.creDrw():this.creMob()},bindVp(){const h=E.deb(()=>this.hndVp(),150);E.add(window,'resize',h);screen?.orientation&&E.add(screen.orientation,'change',h)},hndVp(){const w=innerWidth;this.clnEl(w);if(w>=1201&&!this.ini.d){this.creDsk()}else if(w>=768&&w<=1200&&!this.ini.dr){this.creDrw()}else if(w<768&&!this.ini.m){this.creMob()}},clnEl(w){const t=[];if(w>=1201){t.push(()=>{const db=document.querySelector('.drawer-button-container');db&&(db.remove(),D.inv('.drawer-button-container'))});this.ini.dr=0}if(w>=768&&w<=1200){t.push(()=>{const dm=document.querySelector('.nav-container');dm&&(dm.remove(),D.inv('.nav-container'))});this.ini.d=0}if(w<768){t.push(()=>{['.drawer-button-container','#desktop-drawer','#desktop-drawer-overlay','.nav-container'].map(s=>document.querySelector(s)).forEach(e=>e?.remove());D.inv('.drawer-button-container');D.inv('#desktop-drawer');D.inv('.nav-container')});this.ini.dr=this.ini.d=0}t.length&&A.bat(t)},creDsk(){if(this.ini.d)return;const hn=D.get('.header-nav.blur-bg');if(!hn)return;const fe=hn.querySelector('.flex-fill');if(!fe)return;const mc=document.createElement('div');mc.className='nav-container';mc.innerHTML=`<ul class="nav navbar-menu text-xs order-1 order-md-2 position-relative topgj_r">${m.map((it,i)=>B.itm(it,i)).join('')}</ul>`;fe.insertAdjacentElement('afterend',mc);this.ini.d=1},creDbtn(){if(document.getElementById('desktop-drawer-toggle'))return;const hn=D.get('.header-nav.blur-bg');if(!hn)return;const ht=hn.querySelector('.header-tools');if(!ht)return;const db=document.createElement('div');db.className='drawer-button-container';db.innerHTML='<div class="desktop-drawer-toggle" id="desktop-drawer-toggle" aria-expanded="false" aria-label="打开快捷菜单"><span class="menu-bar"></span><span class="menu-bar"></span><span class="menu-bar"></span></div>';ht.insertAdjacentElement('afterend',db)},creMob(){if(this.ini.m)return;const mn=D.get('.mobile-nav');if(!mn)return;const ub=mn.querySelector('.user-btn');if(!ub)return;const qt=document.createElement('div');qt.className='quick-tools-container mt-3';const te=document.createElement('div');te.className='quick-tools-title';te.innerHTML='<i class="iconfont icon-seting"></i><span>快捷工具</span>';const cc=document.createElement('div');cc.className='quick-tools-categories';const f=document.createDocumentFragment();m.forEach((c,i)=>f.appendChild(B.mob(c,i)));cc.appendChild(f);qt.append(te,cc);E.deleg(qt,'click','.category-title',function(){MC.tog(this.getAttribute('data-category'))});ub.insertAdjacentElement('afterend',qt);this.ini.m=1},creDrw(){if(this.ini.dr)return;this.creDbtn();const o=document.createElement('div');Object.assign(o,{className:'desktop-drawer-overlay',id:'desktop-drawer-overlay'});const d=document.createElement('div');Object.assign(d,{className:'desktop-drawer',id:'desktop-drawer'});d.innerHTML=B.drw();document.body.append(o,d);DC.ini();this.ini.dr=1}};const ini=()=>{try{const hn=document.querySelector('.header-nav');if(hn){const ob=new IntersectionObserver(en=>{en.forEach(e=>{e.isIntersecting&&(MI.ini(),ob.disconnect())})},{threshold:.1});ob.observe(hn)}else{requestIdleCallback?requestIdleCallback(()=>MI.ini(),{timeout:1e3}):setTimeout(()=>MI.ini(),100)}}catch(e){console.error('菜单初始化失败:',e);setTimeout(()=>MI.ini(),500)}};E.add(window,'beforeunload',()=>{E.clr();D.clr();B.clr()});document.readyState==='loading'?document.addEventListener('DOMContentLoaded',ini):ini()})()</script>
<!--wp-compress-html compression-->
<?php
echo ob_get_clean();
}
?>
效果展示:

代码更新修复:
1:修复主题启用压缩代码后导致快捷菜单不生效;
2:修复显示逻辑,确保只在桌面端显示,移动端隐藏;
3:2025年9月15日更新
- 增加了自适应模式,完美适配onenav一为导航V5版本(V4未做测试,如有BUG请留言反馈!)
- 重新设计了桌面端,Pad端和移动端的样式,确保各种设备的兼容性
- 优化了代码若干,提高了加载速度
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...