为未完成任务添加重试按钮
This commit is contained in:
parent
c47cd3fb0d
commit
826b080da0
@ -34,12 +34,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="操作" width="280">
|
<el-table-column label="操作" width="360">
|
||||||
<template #default="scoped">
|
<template #default="scoped">
|
||||||
<span>
|
<span>
|
||||||
<el-button @click="downloadTask(scoped.row.download)" :disabled="scoped.row.status !== '下载完成'">下载</el-button>
|
<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="changeGalleryCollect(scoped.row.gid, scoped.row.isCollect)">{{scoped.row.isCollect ? '取消收藏' : '收藏'}}</el-button>
|
||||||
<el-button @click="readOnlineGallery(scoped.row)">在线看</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>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -123,6 +128,7 @@ let username = computed(() => {
|
|||||||
|
|
||||||
//防抖计时器
|
//防抖计时器
|
||||||
let debounceTimer = 0
|
let debounceTimer = 0
|
||||||
|
let retryingGids = ref(new Set())
|
||||||
//是否加载完成
|
//是否加载完成
|
||||||
let loadComplete = computed(() => {
|
let loadComplete = computed(() => {
|
||||||
return store.state.loadComplete
|
return store.state.loadComplete
|
||||||
@ -220,6 +226,16 @@ function downloadTask(link){
|
|||||||
function deleteGallery(gid){
|
function deleteGallery(gid){
|
||||||
store.dispatch("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){
|
function readOnlineGallery(gallery){
|
||||||
store.dispatch("readOnlineGallery", gallery)
|
store.dispatch("readOnlineGallery", gallery)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const actions = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateGalleryTasks(context){
|
updateGalleryTasks(context){
|
||||||
axios.get(GalleryManageUrl, {
|
return axios.get(GalleryManageUrl, {
|
||||||
params:{
|
params:{
|
||||||
AuthCode: context.state.AuthCode,
|
AuthCode: context.state.AuthCode,
|
||||||
type: 'all'
|
type: 'all'
|
||||||
@ -147,6 +147,17 @@ const actions = {
|
|||||||
ElMessage(res.data.data)
|
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){
|
readOnlineGallery(context, gallery){
|
||||||
if(gallery.images !== undefined && gallery.images.length !== 0)
|
if(gallery.images !== undefined && gallery.images.length !== 0)
|
||||||
context.commit("_setReadingGallery", gallery)
|
context.commit("_setReadingGallery", gallery)
|
||||||
@ -217,6 +228,7 @@ const mutations = {
|
|||||||
//处理进度相关
|
//处理进度相关
|
||||||
switch (task.status) {
|
switch (task.status) {
|
||||||
case "已提交":
|
case "已提交":
|
||||||
|
case "等待压缩":
|
||||||
case "压缩中":
|
case "压缩中":
|
||||||
task.progress = task.status
|
task.progress = task.status
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user