更新数据截止日2025.12.15

This commit is contained in:
lychang
2025-12-16 21:18:45 +08:00
parent f0ee65fc53
commit 7169b568dd
12 changed files with 874 additions and 109 deletions

View File

@@ -54,7 +54,7 @@ function generateReport() {
showLoading();
fetch(`/api/reports/daily?date=${date}`)
fetch(`api/reports/daily?date=${date}`)
.then(response => response.json())
.then(data => {
hideLoading();

View File

@@ -12,7 +12,7 @@ document.addEventListener('DOMContentLoaded', function () {
// 加载统计信息
async function loadStatistics() {
try {
const response = await fetch('/api/statistics');
const response = await fetch('api/statistics');
const data = await response.json();
if (data) {
const stats = data;
@@ -29,7 +29,7 @@ async function loadStatistics() {
// 加载按群组分组的消息统计
async function loadGroupMessages() {
try {
const response = await fetch('/api/groups');
const response = await fetch('api/groups');
const data = await response.json();
const groupList = document.getElementById('groupList');
@@ -111,7 +111,6 @@ function selectGroup(groupId) {
// 加载更多消息
async function loadMoreMessages() {
await loadMessages();
currentOffset += limit;
}
// 关闭聊天记录模态框
@@ -198,8 +197,7 @@ async function loadMessages() {
chatMessages.innerHTML = '<div class="loading">暂无消息</div>';
return;
}
let url = `/api/group_messages?limit=${limit}&offset=${currentOffset}&group_id=${currentGroupId}`;
let url = `api/group_messages?limit=${limit}&offset=${currentOffset}&group_id=${currentGroupId}`;
const response = await fetch(url);
const data = await response.json();
@@ -207,36 +205,32 @@ async function loadMessages() {
if (data.success) {
const messages = data.messages || [];
if (messages.length === 0) {
if (currentOffset === 0) {
chatMessages.innerHTML = '<div class="loading">暂无消息</div>';
}
document.getElementById('messageCountDisplay').textContent = `消息数量: ${data.total || 0}`;
document.getElementById('latestTime').textContent = `最新消息: ${data.lastest_time || '暂无'}`;
return;
}
// 如果是第一次加载(offset=0),清空消息区域
if (currentOffset === 0) {
chatMessages.innerHTML = '';
}
if (messages.length === 0) {
if (currentOffset === 0) {
chatMessages.innerHTML = '<div class="loading">暂无消息</div>';
document.getElementById('messageCountDisplay').textContent = `消息数量: 0`;
document.getElementById('latestTime').textContent = `最新消息: 暂无`;
}
return;
}
// 将新消息插入到消息区域的开头(向上加载历史消息)
messages.forEach(message => {
const messageDiv = createMessageElement(message);
if (currentOffset === 0) {
chatMessages.appendChild(messageDiv);
} else {
// 加载更多消息时,插入到现有消息的前面
chatMessages.insertBefore(messageDiv, chatMessages.firstChild);
}
chatMessages.insertBefore(messageDiv, chatMessages.firstChild);
});
// 更新偏移量,用于下次加载更多
currentOffset += limit;
document.getElementById('messageCountDisplay').textContent = `消息数量: ${data.total || 0}`;
document.getElementById('latestTime').textContent = `最新消息: ${data.lastest_time || '暂无'}`;
} else {
chatMessages.innerHTML = '<div class="error">加载消息失败</div>';
}

View File

@@ -7,7 +7,7 @@ let groupList = []; // 存储群组列表
// 加载群组列表
async function loadGroupList() {
try {
const response = await fetch('/api/groups');
const response = await fetch('api/groups');
const result = await response.json();
if (result.success) {
@@ -100,7 +100,7 @@ async function loadQAList() {
const endTime = endDateFilter ? endDateFilter.value : '';
// 构建查询URL
let url = '/api/qa';
let url = 'api/qa';
const params = new URLSearchParams();
if (keyword) params.append('keyword', keyword);
@@ -183,7 +183,7 @@ async function displayQAList(qaList) {
let messageMap = {};
if (allMessageIds.length > 0) {
try {
const response = await fetch('/api/messages_by_ids', {
const response = await fetch('api/messages_by_ids', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -280,7 +280,7 @@ async function searchMessages() {
const qaListContainer = document.getElementById('qaList');
qaListContainer.innerHTML = '<div class="loading">搜索中...</div>';
const response = await fetch(`/api/search_messages?keyword=${encodeURIComponent(keyword)}`);
const response = await fetch(`api/search_messages?keyword=${encodeURIComponent(keyword)}`);
const result = await response.json();
if (result.success) {
@@ -321,7 +321,7 @@ async function advancedSearch() {
if (startDate) params.append('start_time', startDate);
if (endDate) params.append('end_time', endDate);
const response = await fetch(`/api/qa?${params.toString()}`);
const response = await fetch(`api/qa?${params.toString()}`);
const result = await response.json();
if (result.success) {
@@ -411,7 +411,7 @@ async function showSearchSuggestions() {
try {
// 调用后端API获取搜索建议
const response = await fetch(`/api/search_suggestions?keyword=${encodeURIComponent(keyword)}`);
const response = await fetch(`api/search_suggestions?keyword=${encodeURIComponent(keyword)}`);
const result = await response.json();
if (result.success && result.suggestions.length > 0) {
@@ -512,7 +512,7 @@ function openCreateModal() {
// 编辑QA
async function editQA(qaId) {
try {
const response = await fetch(`/api/qa/${qaId}`);
const response = await fetch(`api/qa/${qaId}`);
const result = await response.json();
if (result.success) {
@@ -620,7 +620,7 @@ async function batchDeleteQA() {
}
try {
const response = await fetch('/api/qa/batch', {
const response = await fetch('api/qa/batch', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
@@ -665,7 +665,7 @@ async function searchQuestionMessages() {
const groupIdSelect = document.getElementById('groupId');
const groupId = groupIdSelect.value;
try {
const url = `/api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
const url = `api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
const response = await fetch(url);
const result = await response.json();
if (result.success) {
@@ -721,7 +721,7 @@ async function searchAnswerMessages() {
const groupId = groupIdSelect.value;
try {
const url = `/api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
const url = `api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
const response = await fetch(url);
const result = await response.json();
@@ -829,7 +829,7 @@ async function saveQA() {
};
try {
const url = currentQA ? `/api/qa/${currentQA.id}` : '/api/qa';
const url = currentQA ? `api/qa/${currentQA.id}` : '/api/qa';
const method = currentQA ? 'PUT' : 'POST';
const response = await fetch(url, {
@@ -859,7 +859,7 @@ async function saveQA() {
// 预览QA
async function previewQA(qaId) {
try {
const response = await fetch(`/api/qa/${qaId}`);
const response = await fetch(`api/qa/${qaId}`);
const result = await response.json();
if (result.success) {
displayPreview(result.qa);
@@ -882,7 +882,7 @@ async function displayPreview(qa) {
if (allMessageIds.length > 0) {
try {
const response = await fetch('/api/messages_by_ids', {
const response = await fetch('api/messages_by_ids', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -972,7 +972,7 @@ async function deleteQA(qaId) {
}
try {
const response = await fetch(`/api/qa/${qaId}`, {
const response = await fetch(`api/qa/${qaId}`, {
method: 'DELETE'
});

View File

@@ -69,7 +69,7 @@ function generateReport() {
showLoading();
fetch(`/api/reports/weekly?week=${weekFormatted}`)
fetch(`api/reports/weekly?week=${weekFormatted}`)
.then(response => response.json())
.then(data => {
hideLoading();