feat: 信息面板增加日志导出JSON功能
- 在操作日志页面添加导出按钮 - 实现exportLogs方法,导出所有过滤后的日志 - 导出文件包含导出时间、筛选条件和完整日志数据 - 文件名使用时间戳格式:logs_export_YYYY-MM-DD.json 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c1cb907ab4
commit
ad1d4fe2a1
@ -107,6 +107,9 @@
|
||||
<button class="action-btn refresh" @click="refreshLogs">
|
||||
<i class="fas fa-sync-alt"></i>刷新
|
||||
</button>
|
||||
<button class="action-btn export" @click="exportLogs">
|
||||
<i class="fas fa-download"></i>导出
|
||||
</button>
|
||||
<button class="action-btn clear" @click="clearLogs">
|
||||
<i class="fas fa-trash"></i>清理
|
||||
</button>
|
||||
@ -381,6 +384,47 @@ const refreshStats = () => {
|
||||
websocketService.getOperationTypes()
|
||||
}
|
||||
|
||||
const exportLogs = () => {
|
||||
// 导出数据结构
|
||||
const exportData = {
|
||||
export_time: new Date().toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}),
|
||||
total_logs: allFilteredLogs.value.length,
|
||||
filters: {
|
||||
type: logTypeFilter.value || 'all',
|
||||
operation: operationFilter.value || 'all'
|
||||
},
|
||||
logs: allFilteredLogs.value
|
||||
}
|
||||
|
||||
// 生成JSON字符串
|
||||
const jsonStr = JSON.stringify(exportData, null, 2)
|
||||
|
||||
// 创建Blob对象
|
||||
const blob = new Blob([jsonStr], { type: 'application/json' })
|
||||
|
||||
// 创建下载链接
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
|
||||
// 生成带时间戳的文件名
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').split('T')[0]
|
||||
link.download = `logs_export_${timestamp}.json`
|
||||
link.href = url
|
||||
|
||||
// 触发下载
|
||||
link.click()
|
||||
|
||||
// 清理URL对象
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
// 辅助方法
|
||||
|
||||
const getLogStatusText = (status) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user