mirror of
https://github.com/putyy/res-downloader.git
synced 2026-01-12 06:04:55 +08:00
perf: save ongoing tasks when deleting records
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
"open_link": "打开链接",
|
||||
"open_file": "打开文件",
|
||||
"delete_row": "删除记录",
|
||||
"delete_tip": "运行中任务无法删除",
|
||||
"cancel_down": "取消下载",
|
||||
"more_operation": "更多操作",
|
||||
"video_decode": "视频解密",
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user