// scripts/panel.js export function createPanel() { const panelId = "automation-ai-panel"; let panel = document.getElementById(panelId); if (panel) return getUIRefs(panel); panel = document.createElement("div"); panel.id = panelId; panel.style.cssText = ` position: fixed; bottom: 24px; right: 24px; z-index: 2147483647; background: white; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.2); padding: 12px; width: 260px; font-size: 14px; font-family: sans-serif; `; panel.innerHTML = `
准备就绪
`; document.body.appendChild(panel); return getUIRefs(panel); } function getUIRefs(panel) { return { btn: panel.querySelector("#voiceBtn"), input: panel.querySelector("#voiceTextInput"), setLoading: (loading) => { panel.querySelector("#aiLoading").style.display = loading ? "inline" : "none"; panel.querySelector("#statusText").style.visibility = loading ? "hidden" : "visible"; }, setRecording: (isRecording) => { const dot = panel.querySelector("#recordingIndicator"); const text = panel.querySelector("#statusText"); if (isRecording) { dot.style.display = "inline-block"; text.innerText = "正在聆听..."; text.style.color = "#ff4d4f"; } else { dot.style.display = "none"; text.innerText = "准备就绪"; text.style.color = "#999"; } } }; }