Skip to content

A full-featured download manager.

feat: Ctrl or ⌘ + Enter quick submit task

Dr_rOot1a12256c4cce
diff --git a/src/renderer/components/Task/AddTask.vue b/src/renderer/components/Task/AddTask.vue
index d9316015..b2e15ffa 100644
--- a/src/renderer/components/Task/AddTask.vue
+++ b/src/renderer/components/Task/AddTask.vue
@@ -258,18 +258,16 @@
this.$refs.uri && this.$refs.uri.focus()
}, 50)
}
+ },
+ visible (current) {
+ if (current === true) {
+ document.addEventListener('keydown', this.handleHotkey)
+ } else {
+ document.removeEventListener('keydown', this.handleHotkey)
+ }
}
},
methods: {
- handleOpen () {
- this.form = initialForm(this.$store.state)
- if (this.taskType === ADD_TASK_TYPE.URI) {
- this.autofillResourceLink()
- setTimeout(() => {
- this.$refs.uri && this.$refs.uri.focus()
- }, 50)
- }
- },
autofillResourceLink () {
const content = this.$electron.clipboard.readText()
const hasResource = detectResource(content)
@@ -280,9 +278,21 @@
this.form.uris = content
}
},
+ handleOpen () {
+ this.form = initialForm(this.$store.state)
+ if (this.taskType === ADD_TASK_TYPE.URI) {
+ this.autofillResourceLink()
+ setTimeout(() => {
+ this.$refs.uri && this.$refs.uri.focus()
+ }, 50)
+ }
+ },
handleOpened () {
this.detectThunderResource(this.form.uris)
},
+ handleCancel (formName) {
+ this.$store.dispatch('app/hideAddTaskDialog')
+ },
handleClose (done) {
this.$store.dispatch('app/hideAddTaskDialog')
this.$store.dispatch('app/updateAddTaskOptions', {})
@@ -290,6 +300,13 @@
handleClosed () {
this.reset()
},
+ handleHotkey (event) {
+ if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) {
+ event.preventDefault()
+
+ this.submitForm('taskForm')
+ }
+ },
handleTabClick (tab, event) {
this.$store.dispatch('app/changeAddTaskType', tab.name)
},
@@ -319,9 +336,6 @@
this.showAdvanced = false
this.form = initialForm(this.$store.state)
},
- handleCancel (formName) {
- this.$store.dispatch('app/hideAddTaskDialog')
- },
buildHeader (form) {
const { userAgent, referer, cookie } = form
const result = []