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: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
`;
panel.innerHTML = `
准备就绪
🤖 思考中...
`;
document.body.appendChild(panel);
return getUIRefs(panel);
}
function getUIRefs(panel) {
const input = panel.querySelector("#voiceTextInput");
const btn = panel.querySelector("#voiceBtn");
const loading = panel.querySelector("#aiLoading");
const statusText = panel.querySelector("#statusText");
return {
input,
btn,
setLoading: (isLoading) => {
loading.style.display = isLoading ? "inline" : "none";
statusText.style.display = isLoading ? "none" : "inline";
input.disabled = isLoading;
if (!isLoading) input.focus();
}
};
}