From a7c7b6cbfad76d051ea7acf945dd582aa65b7146 Mon Sep 17 00:00:00 2001 From: MengYX Date: Wed, 5 Feb 2020 01:53:58 +0800 Subject: [PATCH] Add instant download to avoid memory occupation --- src/App.vue | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index 93a037c..c99d547 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,6 +21,7 @@ 歌曲名 歌手-歌曲名 歌曲名-歌手 + 立即保存 下载全部 @@ -107,6 +108,7 @@ playing_url: "", playing_auto: false, format: '2', + instantDownload: false, workCount: 0, cacheQueue: [], cacheQueueOption: { @@ -174,12 +176,17 @@ handleDoFile(file, worker_id) { this.workers[worker_id](file).then(data => { if (data.status) { - this.tableData.push(data); - this.$notify.success({ - title: '解锁成功', - message: '成功解锁 ' + data.title, - duration: 3000 - }); + if (this.instantDownload) { + this.handleDownload(data); + this.handleDelete(null, data); + } else { + this.tableData.push(data); + this.$notify.success({ + title: '解锁成功', + message: '成功解锁 ' + data.title, + duration: 3000 + }); + } let _rp_data = [data.title, data.artist, data.album]; window._paq.push(["trackEvent", "Unlock", data.rawExt + "," + data.mime, JSON.stringify(_rp_data)]); } else { @@ -207,12 +214,14 @@ handleDelete(index, row) { URL.revokeObjectURL(row.file); URL.revokeObjectURL(row.picture); - this.tableData.splice(index, 1); + if (index != null) { + this.tableData.splice(index, 1); + } }, handleDownload(row) { let a = document.createElement('a'); a.href = row.file; - switch(this.format) { + switch (this.format) { case "1": a.download = row.title + "." + row.ext; break;