⚠️
{{ confirmMessage }}
@@ -377,10 +377,13 @@ export default {
})
// 监听窗口大小变化
window.addEventListener('resize', this.adjustContainerPadding)
+ // 监听ESC键关闭弹框
+ window.addEventListener('keydown', this.handleEscKey)
},
beforeDestroy() {
window.removeEventListener('resize', this.adjustContainerPadding)
+ window.removeEventListener('keydown', this.handleEscKey)
},
updated() {
@@ -391,6 +394,21 @@ export default {
},
methods: {
+ // ESC键关闭弹框
+ handleEscKey(event) {
+ if (event.key === 'Escape' || event.keyCode === 27) {
+ if (this.showSuperCategoryDialog) {
+ this.closeSuperCategoryDialog()
+ } else if (this.showCategoryDialog) {
+ this.closeCategoryDialog()
+ } else if (this.showToolDialog) {
+ this.closeToolDialog()
+ } else if (this.showConfirmDialog) {
+ this.cancelConfirm()
+ }
+ }
+ },
+
// 动态调整容器padding-top
adjustContainerPadding() {
setTimeout(() => {