esc关闭下载弹窗页

pull/2086/head
Sprite137 2024-10-21 20:41:46 +08:00
parent 550917bd16
commit ddd850d80f
1 changed files with 13 additions and 0 deletions

View File

@ -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':