©Copyright 2024-2025 sam-dancing All Rights Reserved Powered by sam-dancing
⚙
`)+'">';
/* === 留言/交流 === */
function loadBoard(type,dom){
api(type+'/list').then(r=>{
dom.innerHTML='';r.data.forEach(m=>{
const d=document.createElement('div');d.textContent=`${m.user}: ${m.text}`;dom.appendChild(d);
});
});
}
function sendBoard(type,form){
form.addEventListener('submit',e=>{
e.preventDefault();
api(type+'/add?text='+encodeURIComponent(form[0].value))
.then(r=>{if(r.ok){form.reset();loadBoard(type,type==='msg'?qs('#msgBoard'):qs('#chatBoard'))}else alert(r.error||'发送失败')});
});
}
sendBoard('msg',qs('#msgForm'));
sendBoard('chat',qs('#chatForm'));
/* === 认证 === */
function showAuth(){qs('#authDialog').showModal();}
qs('#authForm').onsubmit=e=>{
e.preventDefault();
const fd=new FormData(e.target);
const params=new URLSearchParams(fd);
api('auth?'+params).then(r=>{
if(r.ok){uid=r.uid;uname=r.user;qs('#authDialog').close();updateUI();}
else alert(r.error||'失败');
});
};
function updateUI(){
if(uid){qs('#msgForm').style.display='block';qs('#chatForm').style.display='block';api('visit/me').then(r=>alert('您的累计访问:'+r.count));}
else{qs('#msgForm').style.display='none';qs('#chatForm').style.display='none';}
loadBoard('msg',qs('#msgBoard'));loadBoard('chat',qs('#chatBoard'));
}
updateUI();
/* === 统计/在线人数 === */
api('visit/add');
api('visit/total').then(r=>console.log('总访问:'+r.total));
api('visit/online').then(r=>console.log('5分钟内在线:'+r.online));
/* === 工具 === */
function jump(url){if(confirm('即将离开本站前往 '+url))location.href=url;}
function openLink(u){window.open(u,'_blank')}
function openTerms(){alert('使用条款:遵守当地法律,禁止黄赌毒。')}
function delCookie(){localStorage.clear();location.reload()}
/* === 强制结束转圈 === */
window.addEventListener('load',()=>setTimeout(()=>qs('#loader').classList.add('hidden'),1500));
/* === 实时信息 === */
let last=performance.now();
setInterval(()=>{
const p=performance.memory;
if(p)qs('#mem').textContent=(p.usedJSHeapSize/1048576).toFixed(1);
qs('#fps').textContent=Math.round(1000/(performance.now()-last));
last=performance.now();
qs('#read').textContent=Math.round(window.scrollY/(document.body.scrollHeight-window.innerHeight)*100);
},1000);
/* === 液态玻璃 === */
const scr=document.createElement('script');
scr.textContent=`(function(){if(window.liquidGlass){window.liquidGlass.destroy()}function smoothStep(a,b,t){t=Math.max(0,Math.min(1,(t-a)/(b-a)));return t*t*(3-2*t)}function length(x,y){return Math.sqrt(x*x+y*y)}function roundedRectSDF(x,y,w,h,r){const qx=Math.abs(x)-w+r;const qy=Math.abs(y)-h+r;return Math.min(Math.max(qx,qy),0)+length(Math.max(qx,0),Math.max(qy,0))-r}function texture(x,y){return{type:'t',x,y}}function generateId(){return'lg-'+Math.random().toString(36).substr(2,9)}class Shader{constructor(opts={}){this.w=opts.width||300;this.h=opts.height||200;this.canvasDPI=2;this.id=generateId();this.mouse={x:0,y:0};this.create();this.update()}create(){this.cont=document.createElement('div');this.cont.style.cssText=\`width:\${this.w}px;height:\${this.h}px;border-radius:150px;overflow:hidden;position:fixed;top:100px;left:100px;backdrop-filter:url(#\${this.id}_f) blur(.25px) contrast(1.2) brightness(1.05) saturate(1.1);box-shadow:0 4px 8px rgba(0,0,0,.25),0 -10px 25px inset rgba(0,0,0,.15);cursor:grab;pointer-events:auto;\`;document.body.appendChild(this.cont);const svg=document.createElementNS('http://www.w3.org/2000/svg','svg');svg.setAttribute('width',0);svg.setAttribute('height',0);const defs=document.createElementNS('http://www.w3.org/2000/svg','defs');const filter=document.createElementNS('http://www.w3.org/2000/svg','filter');filter.setAttribute('id',this.id+'_f');this.feImage=document.createElementNS('http://www.w3.org/2000/svg','feImage');this.feImage.setAttribute('id',this.id+'_img');this.feImage.setAttribute('width',this.w);this.feImage.setAttribute('height',this.h);this.feDisp=document.createElementNS('http://www.w3.org/2000/svg','feDisplacementMap');this.feDisp.setAttribute('in','SourceGraphic');this.feDisp.setAttribute('in2',this.id+'_img');this.feDisp.setAttribute('xChannelSelector','R');this.feDisp.setAttribute('yChannelSelector','G');filter.appendChild(this.feImage);filter.appendChild(this.feDisp);defs.appendChild(filter);svg.appendChild(defs);document.body.appendChild(svg);this.canvas=document.createElement('canvas');this.canvas.width=this.w*this.canvasDPI;this.canvas.height=this.h*this.canvasDPI;this.ctx=this.canvas.getContext('2d');this.setupDrag()}setupDrag(){let dragging=false,offsetX,offsetY;this.cont.addEventListener('mousedown',e=>{dragging=true;this.cont.style.cursor='grabbing';offsetX=e.clientX-this.cont.offsetLeft;offsetY=e.clientY-this.cont.offsetTop});window.addEventListener('mousemove',e=>{if(!dragging)return;let x=e.clientX-offsetX,y=e.clientY-offsetY;x=Math.max(0,Math.min(window.innerWidth-this.w,x));y=Math.max(0,Math.min(window.innerHeight-this.h,y));this.cont.style.left=x+'px';this.cont.style.top=y+'px';this.mouse.x=(e.clientX-x)/this.w;this.mouse.y=(e.clientY-y)/this.h;this.update()});window.addEventListener('mouseup',()=>{dragging=false;this.cont.style.cursor='grab'})}update(){const w=this.canvas.width,h=this.canvas.height,img=new Uint8ClampedArray(w*h*4);for(let i=0;i