QuantumToken

管理后台 · 请使用管理员账号登录
"); return html+inj; } function setVisual(on){ codeState.visual=on; if(on && codeState.preview) setPreview(false); $("#codeEditwrap").classList.toggle("show-visual",on); $("#visualPane").style.display=on?"flex":"none"; $("#codeVisualBtn").textContent=on?"📝 退出可视化":"🎨 可视化编辑"; if(on){ $("#codeVisual").srcdoc=_injectBridge($("#codeEditor").value); } } window.addEventListener("message",ev=>{ if(!codeState.visual) return; const frame=$("#codeVisual"); if(frame.contentWindow && ev.source!==frame.contentWindow) return; if(ev.data && ev.data.type==="qt-visual-change" && typeof ev.data.html==="string"){ $("#codeEditor").value=ev.data.html; codeState.dirty=true; } }); function bindCodeEvents(){ $("#codeEditor").addEventListener("input",()=>{ codeState.dirty=true; updatePreview(); }); $("#codePreviewBtn").onclick=()=>setPreview(!codeState.preview); $("#codeVisualBtn").onclick=()=>setVisual(!codeState.visual); $("#codeSaveBtn").onclick=saveCode; $("#codeExplainFileBtn").onclick=()=>runExplain(true); $("#codeExplainSelBtn").onclick=()=>runExplain(false); document.querySelectorAll("#codeModelChips .model-chip").forEach(chip=>{ chip.onclick=()=>{ document.querySelectorAll("#codeModelChips .model-chip").forEach(c=>c.classList.remove("active")); chip.classList.add("active"); }; }); // 编辑器底部留白 = 卡片实际高度(收起时自动收窄) function syncEditGap(){ const wrap=$("#codeEditwrap"), card=$("#askXiaoCard"); const pad=window.innerWidth<=760?24:40; wrap.style.marginBottom=(card.offsetHeight+pad)+"px"; } window.addEventListener("resize",syncEditGap); setTimeout(syncEditGap,50); // 收起/展开 $("#askXiaoToggle").onclick=(e)=>{ e.stopPropagation(); const card=$("#askXiaoCard"); card.classList.toggle("collapsed"); $("#askXiaoToggle").textContent=card.classList.contains("collapsed")?"+":"—"; setTimeout(syncEditGap,30); }; // 拖动(跟随鼠标) (function(){ const card=$("#askXiaoCard"), handle=$("#askXiaoDrag"); let dx=0,dy=0,dragging=false,moved=false; function down(e){ dragging=true;moved=false; const p=e.touches?e.touches[0]:e; const r=card.getBoundingClientRect(); dx=p.clientX-r.left; dy=p.clientY-r.top; card.style.transition="none"; e.preventDefault(); } function move(e){ if(!dragging)return; moved=true; const p=e.touches?e.touches[0]:e; let x=p.clientX-dx, y=p.clientY-dy; const w=card.offsetWidth,h=card.offsetHeight; x=Math.max(0,Math.min(x,window.innerWidth-w)); y=Math.max(0,Math.min(y,window.innerHeight-h)); card.style.left=x+"px"; card.style.top=y+"px"; card.style.right="auto"; card.style.bottom="auto"; } function up(){ dragging=false; card.style.transition=""; } handle.addEventListener("mousedown",down); document.addEventListener("mousemove",move); document.addEventListener("mouseup",up); handle.addEventListener("touchstart",down,{passive:false}); document.addEventListener("touchmove",move,{passive:false}); document.addEventListener("touchend",up); })(); $("#codeHistoryBtn").onclick=showHistory; }
🤖
🤖
小艾 · AI 管家QuantumToken 后台助手