From 5a7324654548e72cb251ef9ea22059f44970a2ac Mon Sep 17 00:00:00 2001 From: purocean Date: Fri, 3 May 2019 20:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=92=E5=85=A5=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E9=93=BE=E6=8E=A5=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Editor.vue | 2 ++ frontend/src/components/Filter.vue | 1 - frontend/src/components/Tree.vue | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Editor.vue b/frontend/src/components/Editor.vue index 13357dd0..a8ebeecd 100644 --- a/frontend/src/components/Editor.vue +++ b/frontend/src/components/Editor.vue @@ -27,12 +27,14 @@ export default { this.onGotAmdLoader() } window.addEventListener('resize', this.resize) + this.$bus.on('editor-insert-value', this.insert) this.$bus.on('editor-replace-value', this.replaceValue) this.$bus.on('editor-toggle-wrap', this.toggleWrap) }, beforeDestroy () { window.removeEventListener('paste', this.paste) window.removeEventListener('resize', this.resize) + this.$bus.off('editor-insert-value', this.insert) this.$bus.off('editor-replace-value', this.replaceValue) this.$bus.off('editor-toggle-wrap', this.toggleWrap) }, diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index dba3c425..87313082 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -168,7 +168,6 @@ export default { const file = item || this.selected if (file) { this.$emit('choose-file', file) - this.$bus.emit('choose-file', file) } }, switchTab (tab = null) { diff --git a/frontend/src/components/Tree.vue b/frontend/src/components/Tree.vue index a61378f6..6a6d3cca 100644 --- a/frontend/src/components/Tree.vue +++ b/frontend/src/components/Tree.vue @@ -13,7 +13,7 @@ @delete="onDelete" />
- +
@@ -105,8 +105,21 @@ export default { this.init(null, path) }, keydownHandler (e) { - if (e.key === 'p' && e.ctrlKey) { - this.showFilter = true + if (e.key === 'i' && e.ctrlKey && e.altKey) { + this.showFilter = f => { + if (this.file) { + const relativePath = f.path.replace(this.file.path.substr(0, this.file.path.lastIndexOf('/')), '.') + this.$bus.emit('editor-insert-value', `[${f.name.replace(/\.[^.]$/, '')}](${encodeURI(relativePath)})`) + } + this.showFilter = false + } + e.preventDefault() + e.stopPropagation() + } else if (e.key === 'p' && e.ctrlKey) { + this.showFilter = f => { + this.$bus.emit('choose-file', f) + this.showFilter = false + } e.preventDefault() e.stopPropagation() } else if (e.key === 'Escape' && this.showFilter) {