diff --git a/core/http.go b/core/http.go index 74de2df..0a74d91 100644 --- a/core/http.go +++ b/core/http.go @@ -324,11 +324,13 @@ func (h *HttpServer) clear(w http.ResponseWriter, r *http.Request) { func (h *HttpServer) delete(w http.ResponseWriter, r *http.Request) { var data struct { - Sign string `json:"sign"` + Sign []string `json:"sign"` } err := json.NewDecoder(r.Body).Decode(&data) - if err == nil && data.Sign != "" { - resourceOnce.delete(data.Sign) + if err == nil && len(data.Sign) > 0 { + for _, v := range data.Sign { + resourceOnce.delete(v) + } } h.success(w) } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 68ff286..018b99d 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -76,6 +76,7 @@ "open_link": "Open Link", "open_file": "Open File", "delete_row": "Delete Row", + "delete_tip": "Running tasks cannot be deleted", "cancel_down": "Cancel Download", "more_operation": "More Operations", "video_decode": "WxDecrypt", diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 07bb2ff..0c912f8 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -76,6 +76,7 @@ "open_link": "打开链接", "open_file": "打开文件", "delete_row": "删除记录", + "delete_tip": "运行中任务无法删除", "cancel_down": "取消下载", "more_operation": "更多操作", "video_decode": "视频解密", diff --git a/frontend/src/views/index.vue b/frontend/src/views/index.vue index 333cf92..8827742 100644 --- a/frontend/src/views/index.vue +++ b/frontend/src/views/index.vue @@ -629,7 +629,11 @@ const dataAction = (row: appType.MediaInfo, index: number, type: string) => { decodeWxFile(row, index) break case "delete": - appApi.delete({sign: row.UrlSign}).then(() => { + if (row.Status === "pending" || row.Status === "running") { + window?.$message?.error(t("index.delete_tip")) + return + } + appApi.delete({sign: [row.UrlSign]}).then(() => { data.value.splice(index, 1) cacheData() }) @@ -813,25 +817,30 @@ const close = () => { store.unsetProxy() } -const clear = () => { +const clear = async () => { + const newData = [] as any[] + const signs: string[] = [] if (checkedRowKeysValue.value.length > 0) { - let newData = [] as any[] data.value.forEach((item, index) => { - if (checkedRowKeysValue.value.includes(item.Id)) { - appApi.delete({sign: item.UrlSign}) + if (checkedRowKeysValue.value.includes(item.Id) && item.Status !== "pending" && item.Status !== "running") { + signs.push(item.UrlSign) } else { newData.push(item) } }) - data.value = newData checkedRowKeysValue.value = [] - cacheData() - return + } else { + data.value.forEach((item, index) => { + if (item.Status === "pending" || item.Status === "running") { + newData.push(item) + } else { + signs.push(item.UrlSign) + } + }) } - - data.value = [] - localStorage.setItem("resources-data", "") - appApi.clear() + await appApi.delete({sign: signs}) + data.value = newData + cacheData() } const decodeWxFile = (row: appType.MediaInfo, index: number) => {