From af214138aabcc24874e6d52e145bf861764ee6b9 Mon Sep 17 00:00:00 2001 From: purocean Date: Mon, 18 Feb 2019 15:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=88=96=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E6=96=87=E4=BB=B6=E5=90=8E=E8=87=AA=E5=8A=A8=E6=89=93?= =?UTF-8?q?=E5=BC=80=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Tree.vue | 17 ++++++++++++----- frontend/src/components/TreeNode.vue | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/Tree.vue b/frontend/src/components/Tree.vue index c4fe04bb..88f56304 100644 --- a/frontend/src/components/Tree.vue +++ b/frontend/src/components/Tree.vue @@ -67,7 +67,7 @@ export default { this.$bus.$emit('toggle-readme') } }, - init (repo = null) { + init (repo = null, path = null) { if (repo) { this.repo = repo this.tree = null @@ -76,6 +76,12 @@ export default { File.tree(this.repo, tree => { this.tree = tree + + if (path) { + this.$nextTick(() => { + this.$bus.emit('choose-file', { path }) + }) + } }) }, onDelete (path) { @@ -86,16 +92,17 @@ export default { this.init() }, - onMove (oldPath) { + onMove ({ oldPath, newPath }) { // 移动了正在编辑的文件或者其父目录 if (this.file && this.file.path.startsWith(oldPath)) { this.file = null + this.init(null, newPath) + } else { + this.init() } - - this.init() }, change (path) { - this.init() + this.init(null, path) }, keydownHandler (e) { if (e.key === 'p' && e.ctrlKey) { diff --git a/frontend/src/components/TreeNode.vue b/frontend/src/components/TreeNode.vue index 29d11cd6..0ad11ecc 100644 --- a/frontend/src/components/TreeNode.vue +++ b/frontend/src/components/TreeNode.vue @@ -1,6 +1,6 @@