From 5df253458676dc18e0e05cb264238cb8bb15c8a9 Mon Sep 17 00:00:00 2001 From: purocean Date: Mon, 9 Dec 2019 17:25:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=A8=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=88=9B=E5=BB=BA=E6=96=87=E4=BB=B6=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/TreeNode.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/TreeNode.vue b/frontend/src/components/TreeNode.vue index 3021f564..b7ac812b 100644 --- a/frontend/src/components/TreeNode.vue +++ b/frontend/src/components/TreeNode.vue @@ -99,7 +99,7 @@ export default { additional.push({ id: 'duplicate', label: '重复文件', onClick: () => this.duplicateFile() }) } - this.$contextMenu.show(additional.concat(menu)) + this.$contextMenu.show(additional.concat(menu, [{ id: 'create', label: '当前目录创建新文件', onClick: () => this.createFile() }])) } else { this.$contextMenu.show(menu) } @@ -158,10 +158,12 @@ export default { }, async createFile (path = null, content = null) { if (path === null) { + const currentPath = this.item.type === 'dir' ? this.item.path : File.dirname(this.item.path) + let filename = await this.$modal.input({ title: '创建文件(加密文件以 .c.md 结尾)', hint: '文件路径', - content: '当前路径:' + this.item.path, + content: '当前路径:' + currentPath, value: 'new.md' }) @@ -173,7 +175,7 @@ export default { filename = filename.replace(/\/$/, '') + '.md' } - path = this.item.path.replace(/\/$/, '') + '/' + filename + path = currentPath.replace(/\/$/, '') + '/' + filename } if (!path) {