为未完成任务添加重试按钮

This commit is contained in:
root 2026-07-11 15:02:04 +08:00
parent c47cd3fb0d
commit 826b080da0
2 changed files with 32 additions and 4 deletions

View File

@ -34,12 +34,17 @@
</template>
</el-table-column>
<el-table-column label="操作" width="280">
<el-table-column label="操作" width="360">
<template #default="scoped">
<span>
<el-button @click="downloadTask(scoped.row.download)" :disabled="scoped.row.status !== '下载完成'">下载</el-button>
<el-button @click="changeGalleryCollect(scoped.row.gid, scoped.row.isCollect)">{{scoped.row.isCollect ? '取消收藏' : '收藏'}}</el-button>
<el-button @click="readOnlineGallery(scoped.row)">在线看</el-button>
<el-button v-if="scoped.row.status !== '下载完成'"
@click="retryGallery(scoped.row.gid)"
:loading="retryingGids.has(scoped.row.gid)">
重试
</el-button>
</span>
</template>
</el-table-column>
@ -123,6 +128,7 @@ let username = computed(() => {
//
let debounceTimer = 0
let retryingGids = ref(new Set())
//
let loadComplete = computed(() => {
return store.state.loadComplete
@ -220,6 +226,16 @@ function downloadTask(link){
function deleteGallery(gid){
store.dispatch("deleteGallery", gid)
}
async function retryGallery(gid){
if(retryingGids.value.has(gid))
return
retryingGids.value.add(gid)
try {
await store.dispatch("retryGallery", gid)
} finally {
retryingGids.value.delete(gid)
}
}
function readOnlineGallery(gallery){
store.dispatch("readOnlineGallery", gallery)
}
@ -271,4 +287,4 @@ function showThumbnail(gallery){
.detail-info > span {
display: block;
}
</style>
</style>

View File

@ -29,7 +29,7 @@ const actions = {
})
},
updateGalleryTasks(context){
axios.get(GalleryManageUrl, {
return axios.get(GalleryManageUrl, {
params:{
AuthCode: context.state.AuthCode,
type: 'all'
@ -147,6 +147,17 @@ const actions = {
ElMessage(res.data.data)
})
},
retryGallery(context, gid){
return axios.post(GalleryManageUrl + "/retry?" + qs.stringify({
gid, AuthCode: context.state.AuthCode
})).then((res) => {
if(res.data.result === "success"){
ElMessage({message: "重试结果:" + res.data.data, type: "success"})
return context.dispatch("updateGalleryTasks")
}
ElMessage({message: res.data.data || "重试失败", type: "error"})
})
},
readOnlineGallery(context, gallery){
if(gallery.images !== undefined && gallery.images.length !== 0)
context.commit("_setReadingGallery", gallery)
@ -217,6 +228,7 @@ const mutations = {
//处理进度相关
switch (task.status) {
case "已提交":
case "等待压缩":
case "压缩中":
task.progress = task.status
break;
@ -514,4 +526,4 @@ function deleteTask(tasks, key, value){
}
}
let status = ['已提交', '下载中', '等待压缩', '压缩中', '下载完成']
let status = ['已提交', '下载中', '等待压缩', '压缩中', '下载完成']