|
|
@@ -0,0 +1,824 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh-CN">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>WMS智能助手</title>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="warehouse-chat">
|
|
|
+ <!-- 侧边栏 -->
|
|
|
+ <div class="sidebar">
|
|
|
+ <div class="logo">
|
|
|
+ <div class="logo-icon">
|
|
|
+ <span style="font-size: 20px;">🤖</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="nav-buttons">
|
|
|
+ <button class="nav-btn active">
|
|
|
+ <span class="nav-icon">💬</span>
|
|
|
+ </button>
|
|
|
+ <button class="nav-btn">
|
|
|
+ <span class="nav-icon">📊</span>
|
|
|
+ </button>
|
|
|
+ <button class="nav-btn">
|
|
|
+ <span class="nav-icon">🔄</span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 主聊天区域 -->
|
|
|
+ <div class="chat-container">
|
|
|
+ <!-- 欢迎界面 -->
|
|
|
+ <div id="welcome-screen" class="welcome-screen">
|
|
|
+ <div class="welcome-content">
|
|
|
+ <div class="welcome-icon">
|
|
|
+ <span style="font-size: 64px;">🤖</span>
|
|
|
+ </div>
|
|
|
+ <h1 class="welcome-title">我是WMS智能助手,很高兴见到你!</h1>
|
|
|
+ <p class="welcome-subtitle">我可以帮您处理订单加急标记、创建入库预约等任务,请把你的任务交给我~</p>
|
|
|
+
|
|
|
+ <!-- 推荐功能 -->
|
|
|
+ <div class="recommendations">
|
|
|
+ <div class="recommendation-section">
|
|
|
+ <h3>📦 订单加急</h3>
|
|
|
+ <p>例如:"订单SOZ25090400035加急处理"</p>
|
|
|
+ </div>
|
|
|
+ <div class="recommendation-section">
|
|
|
+ <h3>🚚 创建入库预约</h3>
|
|
|
+ <p>例如:"梁涵9月20日上午送100箱货到九干仓,单号T2025072101115676"</p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="examples">
|
|
|
+ <div class="example" onclick="sendExample('订单SOZ25090400035加急处理')">订单SOZ25090400035加急处理</div>
|
|
|
+ <div class="example" onclick="sendExample('梁涵9月20日上午送100箱货到九干仓,单号T2025072101115676')">梁涵9月20日上午送100箱货到九干仓,单号T2025072101115676</div>
|
|
|
+ <div class="example" onclick="sendExample('傲竹,订单BSIM2510100010004预计10月13日上午到货')">傲竹,订单BSIM2510100010004预计10月13日上午到货</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 聊天消息 -->
|
|
|
+ <div id="messages-container" class="messages-container" style="display: none;">
|
|
|
+ <div id="messages"></div>
|
|
|
+
|
|
|
+ <!-- 加载状态 -->
|
|
|
+ <div id="loading-message" class="message assistant" style="display: none;">
|
|
|
+ <div class="message-content">
|
|
|
+ <div class="assistant-message">
|
|
|
+ <div class="assistant-icon">
|
|
|
+ <span style="font-size: 16px;">🤖</span>
|
|
|
+ </div>
|
|
|
+ <div class="typing-indicator">
|
|
|
+ <span class="dot"></span>
|
|
|
+ <span class="dot"></span>
|
|
|
+ <span class="dot"></span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 输入区域 -->
|
|
|
+ <div class="input-container">
|
|
|
+ <div class="input-box">
|
|
|
+ <div class="input-wrapper">
|
|
|
+ <input
|
|
|
+ id="message-input"
|
|
|
+ type="text"
|
|
|
+ placeholder="给WMS智能助手发送消息"
|
|
|
+ class="message-input"
|
|
|
+ onkeypress="handleKeyPress(event)"
|
|
|
+ />
|
|
|
+ <div class="input-actions">
|
|
|
+ <button class="action-btn" title="深度思考">
|
|
|
+ 🧠
|
|
|
+ </button>
|
|
|
+ <button class="action-btn" title="联网搜索">
|
|
|
+ 🌐
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ id="send-btn"
|
|
|
+ class="send-btn"
|
|
|
+ onclick="sendMessage()"
|
|
|
+ >
|
|
|
+ ↑
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <p class="disclaimer">内容由 AI 生成,请仔细核验</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ // 全局变量
|
|
|
+ const API_BASE_URL = 'http://127.0.0.1:8080';
|
|
|
+ let messages = [];
|
|
|
+ let isLoading = false;
|
|
|
+
|
|
|
+ // DOM元素
|
|
|
+ let welcomeScreen;
|
|
|
+ let messagesContainer;
|
|
|
+ let messagesDiv;
|
|
|
+ let messageInput;
|
|
|
+ let sendBtn;
|
|
|
+ let loadingMessage;
|
|
|
+ let currentAssistantElement = null;
|
|
|
+ let currentAssistantText = '';
|
|
|
+
|
|
|
+ // 初始化
|
|
|
+ document.addEventListener('DOMContentLoaded', function() {
|
|
|
+ welcomeScreen = document.getElementById('welcome-screen');
|
|
|
+ messagesContainer = document.getElementById('messages-container');
|
|
|
+ messagesDiv = document.getElementById('messages');
|
|
|
+ messageInput = document.getElementById('message-input');
|
|
|
+ sendBtn = document.getElementById('send-btn');
|
|
|
+ loadingMessage = document.getElementById('loading-message');
|
|
|
+
|
|
|
+ // 自动聚焦输入框
|
|
|
+ messageInput.focus();
|
|
|
+
|
|
|
+ console.log('聊天界面已初始化');
|
|
|
+ });
|
|
|
+
|
|
|
+ // 处理键盘事件
|
|
|
+ function handleKeyPress(event) {
|
|
|
+ if (event.key === 'Enter' && !event.shiftKey) {
|
|
|
+ event.preventDefault();
|
|
|
+ sendMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送示例消息
|
|
|
+ function sendExample(text) {
|
|
|
+ messageInput.value = text;
|
|
|
+ sendMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送消息
|
|
|
+ async function sendMessage() {
|
|
|
+ const message = messageInput.value.trim();
|
|
|
+ if (!message || isLoading) return;
|
|
|
+
|
|
|
+ // 隐藏欢迎界面,显示消息容器
|
|
|
+ if (messages.length === 0) {
|
|
|
+ welcomeScreen.style.display = 'none';
|
|
|
+ messagesContainer.style.display = 'block';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 禁用输入和按钮
|
|
|
+ setInputState(false);
|
|
|
+
|
|
|
+ // 添加用户消息
|
|
|
+ addUserMessage(message);
|
|
|
+
|
|
|
+ // 显示加载状态
|
|
|
+ showLoading();
|
|
|
+
|
|
|
+ // 清空输入框
|
|
|
+ messageInput.value = '';
|
|
|
+
|
|
|
+ try {
|
|
|
+ const response = await fetch(`${API_BASE_URL}/api/agent/chat/stream`, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ message: message
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ await handleStreamResponse(response);
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error('请求失败:', error);
|
|
|
+
|
|
|
+ // 隐藏加载状态
|
|
|
+ hideLoading();
|
|
|
+
|
|
|
+ // 添加错误消息
|
|
|
+ addBotMessage('❌ 网络错误,请稍后重试。');
|
|
|
+ } finally {
|
|
|
+ // 重新启用输入和按钮
|
|
|
+ setInputState(true);
|
|
|
+ messageInput.focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加用户消息
|
|
|
+ function addUserMessage(message) {
|
|
|
+ const messageDiv = document.createElement('div');
|
|
|
+ messageDiv.className = 'message user';
|
|
|
+ messageDiv.innerHTML = `
|
|
|
+ <div class="message-content">
|
|
|
+ <div class="user-message">
|
|
|
+ ${escapeHtml(message)}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+
|
|
|
+ messagesDiv.appendChild(messageDiv);
|
|
|
+ messages.push({ type: 'user', content: message, timestamp: new Date() });
|
|
|
+ scrollToBottom();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加机器人消息
|
|
|
+ function addBotMessage(message) {
|
|
|
+ const messageDiv = document.createElement('div');
|
|
|
+ messageDiv.className = 'message assistant';
|
|
|
+ messageDiv.innerHTML = `
|
|
|
+ <div class="message-content">
|
|
|
+ <div class="assistant-message">
|
|
|
+ <div class="assistant-icon">
|
|
|
+ <span style="font-size: 16px;">🤖</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="assistant-text">${formatMessage(message)}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+
|
|
|
+ messagesDiv.appendChild(messageDiv);
|
|
|
+ messages.push({ type: 'assistant', content: message, timestamp: new Date() });
|
|
|
+ scrollToBottom();
|
|
|
+ }
|
|
|
+
|
|
|
+ function createStreamingBotMessage() {
|
|
|
+ const messageDiv = document.createElement('div');
|
|
|
+ messageDiv.className = 'message assistant';
|
|
|
+ messageDiv.innerHTML = `
|
|
|
+ <div class="message-content">
|
|
|
+ <div class="assistant-message">
|
|
|
+ <div class="assistant-icon">
|
|
|
+ <span style="font-size: 16px;">🤖</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="assistant-text"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+
|
|
|
+ messagesDiv.appendChild(messageDiv);
|
|
|
+ messages.push({ type: 'assistant', content: '', timestamp: new Date() });
|
|
|
+ scrollToBottom();
|
|
|
+ currentAssistantElement = messageDiv.querySelector('.assistant-text');
|
|
|
+ currentAssistantText = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateStreamingBotMessage(text) {
|
|
|
+ if (!currentAssistantElement) {
|
|
|
+ createStreamingBotMessage();
|
|
|
+ }
|
|
|
+ currentAssistantText += text;
|
|
|
+ currentAssistantElement.innerHTML = formatMessage(currentAssistantText);
|
|
|
+ const lastMessage = messages[messages.length - 1];
|
|
|
+ if (lastMessage && lastMessage.type === 'assistant') {
|
|
|
+ lastMessage.content = currentAssistantText;
|
|
|
+ }
|
|
|
+ scrollToBottom();
|
|
|
+ }
|
|
|
+
|
|
|
+ async function handleStreamResponse(response) {
|
|
|
+ if (!response.ok) {
|
|
|
+ hideLoading();
|
|
|
+ addBotMessage('❌ 服务器返回错误,请稍后重试。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const reader = response.body?.getReader();
|
|
|
+ if (!reader) {
|
|
|
+ hideLoading();
|
|
|
+ addBotMessage('❌ 当前浏览器不支持流式响应。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ createStreamingBotMessage();
|
|
|
+
|
|
|
+ const decoder = new TextDecoder('utf-8');
|
|
|
+ let buffer = '';
|
|
|
+ let streamFinished = false;
|
|
|
+
|
|
|
+ try {
|
|
|
+ while (!streamFinished) {
|
|
|
+ const { value, done } = await reader.read();
|
|
|
+ if (done) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ buffer += decoder.decode(value, { stream: true });
|
|
|
+ let boundary = findSseBoundary(buffer);
|
|
|
+
|
|
|
+ while (boundary.index !== -1) {
|
|
|
+ const rawEvent = buffer.slice(0, boundary.index).replace(/\r/g, '').trim();
|
|
|
+ buffer = buffer.slice(boundary.index + boundary.length);
|
|
|
+ streamFinished = processSseEvent(rawEvent) || streamFinished;
|
|
|
+ boundary = findSseBoundary(buffer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (buffer.trim()) {
|
|
|
+ streamFinished = processSseEvent(buffer.replace(/\r/g, '').trim()) || streamFinished;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('处理流式响应失败:', error);
|
|
|
+ updateStreamingBotMessage('\n❌ 响应解析失败,请稍后重试。');
|
|
|
+ } finally {
|
|
|
+ hideLoading();
|
|
|
+ currentAssistantElement = null;
|
|
|
+ currentAssistantText = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function findSseBoundary(text) {
|
|
|
+ const lfIndex = text.indexOf('\n\n');
|
|
|
+ const crlfIndex = text.indexOf('\r\n\r\n');
|
|
|
+
|
|
|
+ if (lfIndex === -1 && crlfIndex === -1) {
|
|
|
+ return { index: -1, length: 0 };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lfIndex === -1) {
|
|
|
+ return { index: crlfIndex, length: 4 };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (crlfIndex === -1) {
|
|
|
+ return { index: lfIndex, length: 2 };
|
|
|
+ }
|
|
|
+
|
|
|
+ return lfIndex < crlfIndex
|
|
|
+ ? { index: lfIndex, length: 2 }
|
|
|
+ : { index: crlfIndex, length: 4 };
|
|
|
+ }
|
|
|
+
|
|
|
+ function processSseEvent(rawEvent) {
|
|
|
+ if (!rawEvent) return false;
|
|
|
+
|
|
|
+ const lines = rawEvent.split('\n');
|
|
|
+ let finished = false;
|
|
|
+
|
|
|
+ for (const line of lines) {
|
|
|
+ const trimmedLine = line.trim();
|
|
|
+ if (!trimmedLine.startsWith('data:')) continue;
|
|
|
+ const dataStr = trimmedLine.slice(5).trim();
|
|
|
+ if (!dataStr) continue;
|
|
|
+
|
|
|
+ if (dataStr === '[DONE]') {
|
|
|
+ finished = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ let payload;
|
|
|
+ try {
|
|
|
+ payload = JSON.parse(dataStr);
|
|
|
+ } catch (error) {
|
|
|
+ console.warn('JSON解析失败,使用原始数据:', dataStr);
|
|
|
+ payload = { type: 'text', text: dataStr };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (payload.type === 'text' && payload.text) {
|
|
|
+ updateStreamingBotMessage(payload.text);
|
|
|
+ } else if (payload.type === 'error') {
|
|
|
+ updateStreamingBotMessage(`\n❌ ${payload.text || '发生未知错误'}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return finished;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示加载状态
|
|
|
+ function showLoading() {
|
|
|
+ isLoading = true;
|
|
|
+ loadingMessage.style.display = 'block';
|
|
|
+ scrollToBottom();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 隐藏加载状态
|
|
|
+ function hideLoading() {
|
|
|
+ isLoading = false;
|
|
|
+ loadingMessage.style.display = 'none';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置输入状态
|
|
|
+ function setInputState(enabled) {
|
|
|
+ messageInput.disabled = !enabled;
|
|
|
+ sendBtn.disabled = !enabled;
|
|
|
+
|
|
|
+ if (enabled) {
|
|
|
+ sendBtn.innerHTML = '↑';
|
|
|
+ } else {
|
|
|
+ sendBtn.innerHTML = '<div class="loading"></div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 滚动到底部
|
|
|
+ function scrollToBottom() {
|
|
|
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
|
|
+ }
|
|
|
+
|
|
|
+ // HTML转义
|
|
|
+ function escapeHtml(text) {
|
|
|
+ const div = document.createElement('div');
|
|
|
+ div.textContent = text;
|
|
|
+ return div.innerHTML;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 格式化消息
|
|
|
+ function formatMessage(content) {
|
|
|
+ // 先进行HTML转义,再处理换行
|
|
|
+ return content.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br>');
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <style>
|
|
|
+ * {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+
|
|
|
+ body {
|
|
|
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
|
|
+ background: #f8f9fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ .warehouse-chat {
|
|
|
+ display: flex;
|
|
|
+ height: 100vh;
|
|
|
+ background: #f8f9fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar {
|
|
|
+ width: 60px;
|
|
|
+ background: #ffffff;
|
|
|
+ border-right: 1px solid #e5e7eb;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ padding: 16px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .logo {
|
|
|
+ margin-bottom: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .logo-icon {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ background: linear-gradient(135deg, #f8f8fc, #d6d1df);
|
|
|
+ border-radius: 8px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-buttons {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-btn {
|
|
|
+ width: 44px;
|
|
|
+ height: 44px;
|
|
|
+ border: none;
|
|
|
+ background: transparent;
|
|
|
+ border-radius: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ transition: all 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-btn:hover {
|
|
|
+ background: #f3f4f6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-btn.active {
|
|
|
+ background: #eef2ff;
|
|
|
+ color: #4f46e5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nav-icon {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .chat-container {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ max-width: 800px;
|
|
|
+ margin: 0 auto;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-screen {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ padding: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-content {
|
|
|
+ text-align: center;
|
|
|
+ max-width: 600px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-icon {
|
|
|
+ font-size: 64px;
|
|
|
+ margin-bottom: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-title {
|
|
|
+ font-size: 28px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #1f2937;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ line-height: 1.3;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-subtitle {
|
|
|
+ font-size: 16px;
|
|
|
+ color: #6b7280;
|
|
|
+ line-height: 1.5;
|
|
|
+ margin: 0 0 32px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .recommendations {
|
|
|
+ text-align: left;
|
|
|
+ background: white;
|
|
|
+ border-radius: 16px;
|
|
|
+ padding: 24px;
|
|
|
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
|
+ margin-top: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .recommendation-section {
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .recommendation-section h3 {
|
|
|
+ font-size: 16px;
|
|
|
+ color: #1f2937;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .recommendation-section p {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #6b7280;
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .examples {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 12px;
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .example {
|
|
|
+ background: #f8f9fa;
|
|
|
+ border: 1px solid #e5e7eb;
|
|
|
+ border-radius: 12px;
|
|
|
+ padding: 12px 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: all 0.2s;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #374151;
|
|
|
+ }
|
|
|
+
|
|
|
+ .example:hover {
|
|
|
+ background: #eef2ff;
|
|
|
+ border-color: #4f46e5;
|
|
|
+ color: #4f46e5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .messages-container {
|
|
|
+ flex: 1;
|
|
|
+ overflow-y: auto;
|
|
|
+ padding: 24px;
|
|
|
+ padding-bottom: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .message {
|
|
|
+ margin-bottom: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .message-content {
|
|
|
+ display: flex;
|
|
|
+ max-width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .user-message {
|
|
|
+ background: #4f46e5;
|
|
|
+ color: white;
|
|
|
+ padding: 12px 18px;
|
|
|
+ border-radius: 18px;
|
|
|
+ margin-left: auto;
|
|
|
+ max-width: 70%;
|
|
|
+ word-wrap: break-word;
|
|
|
+ line-height: 1.4;
|
|
|
+ }
|
|
|
+
|
|
|
+ .assistant-message {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-start;
|
|
|
+ gap: 12px;
|
|
|
+ max-width: 80%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .assistant-icon {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ background: linear-gradient(135deg, #f5f5f7, #cfd5e1);
|
|
|
+ border-radius: 50%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 14px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .assistant-text {
|
|
|
+ background: white;
|
|
|
+ border: 1px solid #e5e7eb;
|
|
|
+ padding: 12px 18px;
|
|
|
+ border-radius: 18px;
|
|
|
+ line-height: 1.5;
|
|
|
+ white-space: pre-line;
|
|
|
+ color: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .typing-indicator {
|
|
|
+ display: flex;
|
|
|
+ gap: 4px;
|
|
|
+ padding: 12px 18px;
|
|
|
+ background: white;
|
|
|
+ border: 1px solid #e5e7eb;
|
|
|
+ border-radius: 18px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dot {
|
|
|
+ width: 6px;
|
|
|
+ height: 6px;
|
|
|
+ background: #9ca3af;
|
|
|
+ border-radius: 50%;
|
|
|
+ animation: typing 1.4s infinite;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dot:nth-child(2) {
|
|
|
+ animation-delay: 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dot:nth-child(3) {
|
|
|
+ animation-delay: 0.4s;
|
|
|
+ }
|
|
|
+
|
|
|
+ @keyframes typing {
|
|
|
+ 0%, 60%, 100% {
|
|
|
+ transform: translateY(0);
|
|
|
+ }
|
|
|
+ 30% {
|
|
|
+ transform: translateY(-10px);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-container {
|
|
|
+ padding: 24px;
|
|
|
+ background: white;
|
|
|
+ border-top: 1px solid #e5e7eb;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-box {
|
|
|
+ max-width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-wrapper {
|
|
|
+ position: relative;
|
|
|
+ background: white;
|
|
|
+ border: 2px solid #e5e7eb;
|
|
|
+ border-radius: 24px;
|
|
|
+ padding: 8px 16px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+ transition: border-color 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-wrapper:focus-within {
|
|
|
+ border-color: #4f46e5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .message-input {
|
|
|
+ flex: 1;
|
|
|
+ border: none;
|
|
|
+ outline: none;
|
|
|
+ font-size: 16px;
|
|
|
+ padding: 8px 0;
|
|
|
+ background: transparent;
|
|
|
+ color: #1f2937;
|
|
|
+ }
|
|
|
+
|
|
|
+ .message-input::placeholder {
|
|
|
+ color: #9ca3af;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-actions {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .action-btn {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ border: none;
|
|
|
+ background: transparent;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 14px;
|
|
|
+ transition: background 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .action-btn:hover {
|
|
|
+ background: #f3f4f6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .send-btn {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ background: #4f46e5;
|
|
|
+ border: none;
|
|
|
+ border-radius: 50%;
|
|
|
+ color: white;
|
|
|
+ cursor: pointer;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ transition: all 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .send-btn:hover:not(:disabled) {
|
|
|
+ background: #4338ca;
|
|
|
+ transform: translateY(-1px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .send-btn:disabled {
|
|
|
+ background: #d1d5db;
|
|
|
+ cursor: not-allowed;
|
|
|
+ }
|
|
|
+
|
|
|
+ .disclaimer {
|
|
|
+ text-align: center;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #9ca3af;
|
|
|
+ margin-top: 12px;
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 响应式设计 */
|
|
|
+ @media (max-width: 768px) {
|
|
|
+ .sidebar {
|
|
|
+ width: 50px;
|
|
|
+ padding: 12px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .welcome-title {
|
|
|
+ font-size: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .messages-container {
|
|
|
+ padding: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-container {
|
|
|
+ padding: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .user-message,
|
|
|
+ .assistant-message {
|
|
|
+ max-width: 90%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .examples {
|
|
|
+ gap: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .example {
|
|
|
+ padding: 10px 12px;
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</body>
|
|
|
+</html>
|