會話管理頁籤增加匯出相關功能

This commit is contained in:
Minidoracat 2025-06-28 01:30:08 +08:00
parent 5e103f10d8
commit 0917214272
6 changed files with 164 additions and 1 deletions

View File

@ -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"
}

View File

@ -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": "用户消息记录已清空"
}

View File

@ -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": "用戶訊息記錄已清空"
}

View File

@ -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;

View File

@ -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');
}
};
/**
* 清理資源
*/

View File

@ -641,7 +641,31 @@
<!-- 會話歷史記錄 -->
<div class="session-history-section">
<div class="session-history-header">
<h4 data-i18n="sessionManagement.sessionHistory">會話歷史</h4>
<div class="session-history-actions">
<button class="btn-small btn-secondary" id="sessionTabExportAllBtn"
data-i18n="sessionHistory.management.exportAll"
data-i18n-title="sessionHistory.management.exportAllTitle"
aria-label="匯出全部會話">
匯出全部
</button>
<button class="btn-small btn-secondary" id="sessionTabClearMessagesBtn"
style="color: var(--warning-color);"
data-i18n="sessionHistory.userMessages.clearAll"
data-i18n-title="sessionHistory.userMessages.clearAllTitle"
aria-label="清空訊息記錄">
清空訊息記錄
</button>
<button class="btn-small btn-secondary" id="sessionTabClearAllBtn"
style="color: var(--error-color);"
data-i18n="sessionHistory.management.clear"
data-i18n-title="sessionHistory.management.clearTitle"
aria-label="清空所有會話">
清空
</button>
</div>
</div>
<div class="session-list" id="sessionHistoryList">
<div class="no-sessions" data-i18n="sessionManagement.noHistory">暫無歷史會話</div>
</div>