/* 门禁(WB):前端放开也要有自己的权限;数据一律走受保护 API */
(function(){
function unlock(){var g=document.getElementById('ixgn-gate');if(g&&g.parentNode)g.parentNode.removeChild(g);}
function deny(){try{sessionStorage.setItem('l0_redirect',location.pathname+location.search);}catch(e){}location.replace('/admin-login.html');}
function hasCookie(n){return new RegExp('(^| )'+n+'=').test(document.cookie);}
if(hasCookie('unified_openid')){unlock();return;}
fetch('/admin-auth.php?action=check',{credentials:'include',cache:'no-store'})
.then(function(r){return r.json();})
.then(function(d){ if(d&&d.code===200){unlock();}else{deny();} })
.catch(function(){var g=document.getElementById('ixgn-gate');if(g)g.textContent='身份校验失败,请刷新页面或重新登录';});
})();