diff --git a/web/static/css/style.css b/web/static/css/style.css index bdb1f645..f8531ea6 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -6112,6 +6112,9 @@ header { .batch-manage-modal-content { max-width: 800px; width: 90vw; + display: flex; + flex-direction: column; + max-height: 85vh; } .batch-manage-header-actions { @@ -6146,8 +6149,12 @@ header { } .batch-manage-body { - max-height: 60vh; + flex: 1; + min-height: 0; overflow-y: auto; + padding: 0; + display: flex; + flex-direction: column; } .batch-conversations-table { @@ -6241,6 +6248,7 @@ header { justify-content: space-between; padding: 16px 24px; border-top: 1px solid var(--border-color); + flex-shrink: 0; } .select-all-checkbox { diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 285a11f9..3d44757f 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -1449,7 +1449,6 @@ async function loadConversations(searchQuery = '') { url += '&search=' + encodeURIComponent(searchQuery.trim()); } const response = await apiFetch(url); - const conversations = await response.json(); const listContainer = document.getElementById('conversations-list'); if (!listContainer) { @@ -1459,6 +1458,14 @@ async function loadConversations(searchQuery = '') { const emptyStateHtml = '
暂无历史对话
'; listContainer.innerHTML = ''; + // 如果响应不是200,显示空状态(友好处理,不显示错误) + if (!response.ok) { + listContainer.innerHTML = emptyStateHtml; + return; + } + + const conversations = await response.json(); + if (!Array.isArray(conversations) || conversations.length === 0) { listContainer.innerHTML = emptyStateHtml; return; @@ -1533,6 +1540,12 @@ async function loadConversations(searchQuery = '') { updateActiveConversation(); } catch (error) { console.error('加载对话列表失败:', error); + // 错误时显示空状态,而不是错误提示(更友好的用户体验) + const listContainer = document.getElementById('conversations-list'); + if (listContainer) { + const emptyStateHtml = '
暂无历史对话
'; + listContainer.innerHTML = emptyStateHtml; + } } } @@ -4056,7 +4069,6 @@ async function loadConversationsWithGroups(searchQuery = '') { url += '&search=' + encodeURIComponent(searchQuery.trim()); } const response = await apiFetch(url); - const conversations = await response.json(); const listContainer = document.getElementById('conversations-list'); if (!listContainer) { @@ -4066,6 +4078,14 @@ async function loadConversationsWithGroups(searchQuery = '') { const emptyStateHtml = '
暂无历史对话
'; listContainer.innerHTML = ''; + // 如果响应不是200,显示空状态(友好处理,不显示错误) + if (!response.ok) { + listContainer.innerHTML = emptyStateHtml; + return; + } + + const conversations = await response.json(); + if (!Array.isArray(conversations) || conversations.length === 0) { listContainer.innerHTML = emptyStateHtml; return; @@ -4136,6 +4156,12 @@ async function loadConversationsWithGroups(searchQuery = '') { updateActiveConversation(); } catch (error) { console.error('加载对话列表失败:', error); + // 错误时显示空状态,而不是错误提示(更友好的用户体验) + const listContainer = document.getElementById('conversations-list'); + if (listContainer) { + const emptyStateHtml = '
暂无历史对话
'; + listContainer.innerHTML = emptyStateHtml; + } } } @@ -4988,7 +5014,14 @@ let allConversationsForBatch = []; async function showBatchManageModal() { try { const response = await apiFetch('/api/conversations?limit=1000'); - allConversationsForBatch = await response.json(); + + // 如果响应不是200,使用空数组(友好处理,不显示错误) + if (!response.ok) { + allConversationsForBatch = []; + } else { + const data = await response.json(); + allConversationsForBatch = Array.isArray(data) ? data : []; + } const modal = document.getElementById('batch-manage-modal'); const countEl = document.getElementById('batch-manage-count'); @@ -5002,7 +5035,17 @@ async function showBatchManageModal() { } } catch (error) { console.error('加载对话列表失败:', error); - alert('加载对话列表失败'); + // 错误时使用空数组,不显示错误提示(更友好的用户体验) + allConversationsForBatch = []; + const modal = document.getElementById('batch-manage-modal'); + const countEl = document.getElementById('batch-manage-count'); + if (countEl) { + countEl.textContent = 0; + } + if (modal) { + renderBatchConversations(); + modal.style.display = 'flex'; + } } }