Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

46 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function sendMessage() {
const input = document.getElementById('userInput');
const chatArea = document.getElementById('chatArea');
const text = input.value.trim();
if (!text) return;
// 显示用户消息
const userMsg = document.createElement('div');
userMsg.className = 'message user';
userMsg.innerHTML = `
<div class="bubble">${text.replace(/\n/g, '<br>')}</div>
<div class="avatar">👤</div>
`;
chatArea.appendChild(userMsg);
// 清空输入框
input.value = '';
// 模拟知秋回复后续接入真实API
setTimeout(() => {
const botMsg = document.createElement('div');
botMsg.className = 'message bot';
botMsg.innerHTML = `
<div class="avatar">💙</div>
<div class="bubble">收到!知秋正在处理中...🌊<br>(API接入后这里会显示真实回复)</div>
`;
chatArea.appendChild(botMsg);
chatArea.scrollTop = chatArea.scrollHeight;
}, 500);
chatArea.scrollTop = chatArea.scrollHeight;
}
function clearInput() {
document.getElementById('userInput').value = '';
}
// 支持 Ctrl+Enter 发送
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('userInput').addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'Enter') {
sendMessage();
}
});
});