diff --git a/src/components/Side.vue b/src/components/Side.vue index a3e6bc0..2a19edd 100644 --- a/src/components/Side.vue +++ b/src/components/Side.vue @@ -34,12 +34,17 @@ - + @@ -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; } - \ No newline at end of file + diff --git a/src/store/index.js b/src/store/index.js index dc4ff39..62a35b7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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 = ['已提交', '下载中', '等待压缩', '压缩中', '下载完成'] \ No newline at end of file +let status = ['已提交', '下载中', '等待压缩', '压缩中', '下载完成']