From 0917214272c08fe6e597e8963a9732d49f84a6a4 Mon Sep 17 00:00:00 2001 From: Minidoracat Date: Sat, 28 Jun 2025 01:30:08 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=9C=83=E8=A9=B1=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A0=81=E7=B1=A4=E5=A2=9E=E5=8A=A0=E5=8C=AF=E5=87=BA?= =?UTF-8?q?=E7=9B=B8=E9=97=9C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/locales/en/translation.json | 3 + .../web/locales/zh-CN/translation.json | 3 + .../web/locales/zh-TW/translation.json | 3 + .../web/static/css/session-management.css | 59 +++++++++++++++ .../web/static/js/modules/session-manager.js | 71 +++++++++++++++++++ .../web/templates/feedback.html | 26 ++++++- 6 files changed, 164 insertions(+), 1 deletion(-) diff --git a/src/mcp_feedback_enhanced/web/locales/en/translation.json b/src/mcp_feedback_enhanced/web/locales/en/translation.json index 7ab9db2..fbfb975 100644 --- a/src/mcp_feedback_enhanced/web/locales/en/translation.json +++ b/src/mcp_feedback_enhanced/web/locales/en/translation.json @@ -254,10 +254,12 @@ "export": "Export", "clear": "Clear", "exportAll": "Export All", + "exportAllTitle": "Export all session history to file", "exportSingle": "Export This Session", "confirmClear": "Are you sure you want to clear all session history?", "exportSuccess": "Session history exported successfully", "clearSuccess": "Session history cleared successfully", + "clearTitle": "Clear all session history records", "description": "Manage locally stored session history records, including retention period settings and data export functionality", "exportDescription": "Export or clear locally stored session history records" }, @@ -291,6 +293,7 @@ "imageCount": "Image Count", "timestamp": "Timestamp", "clearAll": "Clear Message Records", + "clearAllTitle": "Clear all user message records from all sessions", "confirmClearAll": "Are you sure you want to clear all user message records from all sessions? This action cannot be undone.", "clearSuccess": "User message records cleared successfully" } diff --git a/src/mcp_feedback_enhanced/web/locales/zh-CN/translation.json b/src/mcp_feedback_enhanced/web/locales/zh-CN/translation.json index 39efe73..ae68858 100644 --- a/src/mcp_feedback_enhanced/web/locales/zh-CN/translation.json +++ b/src/mcp_feedback_enhanced/web/locales/zh-CN/translation.json @@ -254,10 +254,12 @@ "export": "导出", "clear": "清空", "exportAll": "导出全部", + "exportAllTitle": "导出所有会话历史到文件", "exportSingle": "导出此会话", "confirmClear": "确定要清空所有会话历史吗?", "exportSuccess": "会话历史已导出", "clearSuccess": "会话历史已清空", + "clearTitle": "清空所有会话历史记录", "description": "管理本地存储的会话历史记录,包括保存期限设定和数据导出功能", "exportDescription": "导出或清空本地存储的会话历史记录" }, @@ -291,6 +293,7 @@ "imageCount": "图片数量", "timestamp": "时间戳", "clearAll": "清空消息记录", + "clearAllTitle": "清空所有会话的用户消息记录", "confirmClearAll": "确定要清空所有会话的用户消息记录吗?此操作无法撤销。", "clearSuccess": "用户消息记录已清空" } diff --git a/src/mcp_feedback_enhanced/web/locales/zh-TW/translation.json b/src/mcp_feedback_enhanced/web/locales/zh-TW/translation.json index b60cda7..0d8073b 100644 --- a/src/mcp_feedback_enhanced/web/locales/zh-TW/translation.json +++ b/src/mcp_feedback_enhanced/web/locales/zh-TW/translation.json @@ -259,10 +259,12 @@ "export": "匯出", "clear": "清空", "exportAll": "匯出全部", + "exportAllTitle": "匯出所有會話歷史到檔案", "exportSingle": "匯出此會話", "confirmClear": "確定要清空所有會話歷史嗎?", "exportSuccess": "會話歷史已匯出", "clearSuccess": "會話歷史已清空", + "clearTitle": "清空所有會話歷史記錄", "description": "管理本地儲存的會話歷史記錄,包括保存期限設定和資料匯出功能", "exportDescription": "匯出或清空本地儲存的會話歷史記錄" }, @@ -296,6 +298,7 @@ "imageCount": "圖片數量", "timestamp": "時間戳記", "clearAll": "清空訊息記錄", + "clearAllTitle": "清空所有會話的用戶訊息記錄", "confirmClearAll": "確定要清空所有會話的用戶訊息記錄嗎?此操作無法復原。", "clearSuccess": "用戶訊息記錄已清空" } diff --git a/src/mcp_feedback_enhanced/web/static/css/session-management.css b/src/mcp_feedback_enhanced/web/static/css/session-management.css index 9a52269..043d56b 100644 --- a/src/mcp_feedback_enhanced/web/static/css/session-management.css +++ b/src/mcp_feedback_enhanced/web/static/css/session-management.css @@ -858,6 +858,65 @@ outline-offset: 2px; } +/* ===== 會話歷史區塊標題樣式 ===== */ +.session-history-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 12px; +} + +.session-history-header h4 { + margin: 0; + color: var(--text-primary); + font-size: 16px; + font-weight: 600; +} + +.session-history-actions { + display: flex; + gap: 8px; + align-items: center; +} + +/* 響應式設計 - 小螢幕上的調整 */ +@media (max-width: 768px) { + .session-history-header { + flex-direction: column; + align-items: flex-start; + gap: 12px; + } + + .session-history-actions { + width: 100%; + flex-wrap: wrap; + justify-content: flex-start; + } + + .session-history-actions .btn-small { + font-size: 11px; + padding: 4px 8px; + } +} + +/* 超小螢幕上使用下拉選單替代 */ +@media (max-width: 480px) { + .session-history-actions { + position: relative; + } + + .session-history-actions .btn-small:not(:first-child) { + display: none; + } + + /* 可選:將第一個按鈕改為下拉選單觸發器 */ + .session-history-actions .btn-small:first-child::after { + content: ' ▼'; + font-size: 10px; + margin-left: 4px; + } +} + /* ===== 會話詳情彈窗 ===== */ .session-details-modal { position: fixed; diff --git a/src/mcp_feedback_enhanced/web/static/js/modules/session-manager.js b/src/mcp_feedback_enhanced/web/static/js/modules/session-manager.js index a40ad4a..d8a2c6b 100644 --- a/src/mcp_feedback_enhanced/web/static/js/modules/session-manager.js +++ b/src/mcp_feedback_enhanced/web/static/js/modules/session-manager.js @@ -282,6 +282,43 @@ self.copyCurrentUserContent(); }); } + + // 會話歷史管理按鈕 - 會話管理頁籤 + // 匯出全部按鈕 + const sessionTabExportAllBtn = DOMUtils ? + DOMUtils.safeQuerySelector('#sessionTabExportAllBtn') : + document.querySelector('#sessionTabExportAllBtn'); + if (sessionTabExportAllBtn) { + sessionTabExportAllBtn.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + self.exportSessionHistory(); + }); + } + + // 清空訊息記錄按鈕 + const sessionTabClearMessagesBtn = DOMUtils ? + DOMUtils.safeQuerySelector('#sessionTabClearMessagesBtn') : + document.querySelector('#sessionTabClearMessagesBtn'); + if (sessionTabClearMessagesBtn) { + sessionTabClearMessagesBtn.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + self.clearUserMessages(); + }); + } + + // 清空所有會話按鈕 + const sessionTabClearAllBtn = DOMUtils ? + DOMUtils.safeQuerySelector('#sessionTabClearAllBtn') : + document.querySelector('#sessionTabClearAllBtn'); + if (sessionTabClearAllBtn) { + sessionTabClearAllBtn.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + self.clearSessionHistory(); + }); + } }; /** @@ -627,6 +664,40 @@ } }; + /** + * 清空用戶訊息記錄 + */ + SessionManager.prototype.clearUserMessages = function() { + if (!this.dataManager) { + console.error('📋 DataManager 未初始化'); + return; + } + + const i18n = window.i18nManager; + const confirmMessage = i18n ? + i18n.t('sessionHistory.userMessages.confirmClearAll') : + '確定要清空所有會話的用戶訊息記錄嗎?此操作無法復原。'; + + if (!confirm(confirmMessage)) { + return; + } + + try { + const success = this.dataManager.clearAllUserMessages(); + if (success) { + const successMessage = i18n ? + i18n.t('sessionHistory.userMessages.clearSuccess') : + '用戶訊息記錄已清空'; + this.showMessage(successMessage, 'success'); + } else { + this.showMessage('清空失敗', 'error'); + } + } catch (error) { + console.error('📋 清空用戶訊息記錄失敗:', error); + this.showMessage('清空失敗: ' + error.message, 'error'); + } + }; + /** * 清理資源 */ diff --git a/src/mcp_feedback_enhanced/web/templates/feedback.html b/src/mcp_feedback_enhanced/web/templates/feedback.html index 94462f7..18783df 100644 --- a/src/mcp_feedback_enhanced/web/templates/feedback.html +++ b/src/mcp_feedback_enhanced/web/templates/feedback.html @@ -641,7 +641,31 @@
-

會話歷史

+
+

會話歷史

+
+ + + +
+
暫無歷史會話