feat: add download button to Tables/Images views, add task history delete/clear-all

This commit is contained in:
2026-05-14 16:12:09 +08:00
parent 0e273111a2
commit d585a6baaa
5 changed files with 86 additions and 4 deletions
+28 -2
View File
@@ -62,6 +62,7 @@
<template #prefix><el-icon><Search /></el-icon></template>
</el-input>
<el-button size="small" @click="loadData" :icon="Refresh">刷新</el-button>
<el-button size="small" type="danger" @click="clearAllTasks">清除全部</el-button>
</div>
</div>
@@ -88,10 +89,11 @@
<span class="time-cell">{{ formatTime(row.created_at) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="140" fixed="right">
<el-table-column label="操作" width="180" fixed="right">
<template #default="{ row }">
<el-button type="primary" link size="small" @click="showDetail(row)">详情</el-button>
<el-button v-if="row.status === 'failed'" type="warning" link size="small" @click="retryTask(row)">重试</el-button>
<el-button type="danger" link size="small" @click="deleteTask(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -137,7 +139,7 @@
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Timer, CircleCheck, CircleClose, Loading, Search, Refresh } from '@element-plus/icons-vue'
import api from '../api'
import { useDebounce } from '../composables/useDebounce'
@@ -214,6 +216,30 @@ async function copyPath(text: string) {
}
}
async function deleteTask(row: any) {
try {
await ElMessageBox.confirm(`确定删除任务 #${row.id}`, '确认删除')
await api.delete(`/tasks/${row.id}`)
ElMessage.success('已删除')
loadData()
loadStats()
} catch (err: any) {
if (err !== 'cancel') ElMessage.error(err.response?.data?.detail || '删除失败')
}
}
async function clearAllTasks() {
try {
await ElMessageBox.confirm('确定清除所有任务历史记录?此操作不可撤销。', '确认清除', { type: 'warning' })
await api.delete('/tasks')
ElMessage.success('已清除所有任务历史')
loadData()
loadStats()
} catch (err: any) {
if (err !== 'cancel') ElMessage.error(err.response?.data?.detail || '清除失败')
}
}
async function retryTask(row: any) {
try {
await api.post(`/tasks/${row.id}/retry`)