diff --git a/src/renderer/components/common/DownloadModal.vue b/src/renderer/components/common/DownloadModal.vue index cbee8704..ad09d506 100644 --- a/src/renderer/components/common/DownloadModal.vue +++ b/src/renderer/components/common/DownloadModal.vue @@ -49,6 +49,14 @@ export default { return this.info.meta?.qualitys?.filter(quality => this.checkSource(quality.type)) || [] }, }, + + beforeUnmount() { + document.removeEventListener('keyup', this.handleEscKey) + }, + mounted() { + document.addEventListener('keyup', this.handleEscKey) + }, + methods: { handleClick(quality) { void createDownloadTasks([this.musicInfo], quality) @@ -57,6 +65,11 @@ export default { handleClose() { this.$emit('update:show', false) }, + handleEscKey(event) { + if (event.key === 'Escape') { + this.handleClose() + } + }, getTypeName(quality) { switch (quality) { case 'flac24bit':