feat: 功能优化
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
>
|
||||
<template #action>
|
||||
<a-space>
|
||||
|
||||
|
||||
<a-popconfirm
|
||||
title="确定要删除选中的任务吗?删除后无法恢复。"
|
||||
@confirm="handleBatchDelete"
|
||||
@@ -124,19 +124,7 @@
|
||||
<!-- 操作列 -->
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space>
|
||||
<!-- 预览按钮 -->
|
||||
<a-button
|
||||
v-if="isStatus(record.status, 'success')"
|
||||
type="link"
|
||||
size="small"
|
||||
@click="handlePreview(record)"
|
||||
class="action-btn-preview"
|
||||
>
|
||||
<template #icon>
|
||||
<PlayCircleOutlined />
|
||||
</template>
|
||||
预览
|
||||
</a-button>
|
||||
|
||||
<!-- 下载按钮 -->
|
||||
<a-button
|
||||
v-if="isStatus(record.status, 'success')"
|
||||
@@ -171,23 +159,6 @@
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</div>
|
||||
|
||||
<!-- 预览对话框 -->
|
||||
<a-modal
|
||||
v-model:open="previewVisible"
|
||||
title="视频预览"
|
||||
:footer="null"
|
||||
width="800px"
|
||||
>
|
||||
<video
|
||||
v-if="previewUrl"
|
||||
:src="previewUrl"
|
||||
controls
|
||||
style="width: 100%; max-height: 600px"
|
||||
>
|
||||
您的浏览器不支持视频播放
|
||||
</video>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -242,10 +213,6 @@ useTaskPolling(getDigitalHumanTaskPage, {
|
||||
}
|
||||
})
|
||||
|
||||
// 预览相关
|
||||
const previewVisible = ref(false)
|
||||
const previewUrl = ref('')
|
||||
|
||||
// 表格选择相关
|
||||
const selectedRowKeys = ref([])
|
||||
|
||||
@@ -333,78 +300,17 @@ const isStatus = (status, targetStatus) => {
|
||||
return status === targetStatus || status === targetStatus.toUpperCase()
|
||||
}
|
||||
|
||||
// 预览视频
|
||||
const handlePreview = (record) => {
|
||||
if (!record.resultVideoUrl) {
|
||||
message.warning('该任务暂无视频结果,请稍后再试')
|
||||
return
|
||||
}
|
||||
|
||||
previewUrl.value = record.resultVideoUrl
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
// 下载视频
|
||||
// 下载视频 - 新窗口打开(浏览器自动处理下载)
|
||||
const handleDownload = (record) => {
|
||||
console.log(record)
|
||||
if (!record.resultVideoUrl) {
|
||||
message.warning('该任务暂无视频结果,请稍后再试')
|
||||
return
|
||||
}
|
||||
|
||||
const link = document.createElement('a')
|
||||
link.href = record.resultVideoUrl
|
||||
link.download = `数字人视频_${record.id}_${Date.now()}.mp4`
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
// 批量下载视频
|
||||
const handleBatchDownload = () => {
|
||||
// 获取选中的已完成任务
|
||||
const selectedTasks = list.value.filter(task =>
|
||||
selectedRowKeys.value.includes(task.id) &&
|
||||
isStatus(task.status, 'success')
|
||||
)
|
||||
|
||||
if (selectedTasks.length === 0) {
|
||||
message.warning('请选择已完成的任务')
|
||||
return
|
||||
}
|
||||
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
|
||||
// 逐个直接下载
|
||||
for (const task of selectedTasks) {
|
||||
if (!task.resultVideoUrl) {
|
||||
failCount++
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = task.resultVideoUrl
|
||||
link.download = `数字人视频_${task.id}_${Date.now()}.mp4`
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
successCount++
|
||||
} catch (error) {
|
||||
console.error(`下载任务 ${task.id} 失败:`, error)
|
||||
failCount++
|
||||
}
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
message.success(`已触发 ${successCount} 个文件的下载`)
|
||||
} else if (successCount === 0) {
|
||||
message.error('所有文件下载失败,请重试')
|
||||
} else {
|
||||
message.warning(`成功下载 ${successCount} 个文件,${failCount} 个文件下载失败`)
|
||||
}
|
||||
window.open(record.resultVideoUrl, '_blank')
|
||||
}
|
||||
|
||||
// 批量删除任务
|
||||
|
||||
Reference in New Issue
Block a user