From 7c09793ab62d704b8137d47941864b8be4d3fa36 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Fri, 17 Jan 2020 10:15:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=A0=8F=E8=87=AA=E5=8A=A8=E6=90=9C=E7=B4=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/File/FileList.vue | 36 ++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/File/FileList.vue b/frontend/src/components/File/FileList.vue index c3f47aa1..d5c0b6ae 100644 --- a/frontend/src/components/File/FileList.vue +++ b/frontend/src/components/File/FileList.vue @@ -33,10 +33,14 @@
{ + return { + path, + expanded: this.nodeExpandedDict[path] + } + }) + .filter(d => d.expanded) + .map(d => d.path) } }, methods: { @@ -289,6 +306,13 @@ export default { this.currentFilePath = data.path this.onItemClick(data) }, + onDirClick (data, node) { + const vm = this + setTimeout(() => { + console.log(data.path, node.expanded) + vm.$set(vm.nodeExpandedDict, data.path, node.expanded) + }, 0) + }, sortFiles (nodes) { nodes.forEach(node => { if (node.is_dir) { @@ -318,6 +342,16 @@ export default { return true }) }, + computeExpanded (nodes) { + return nodes.map(node => { + if (node.is_dir) { + node.children = this.computeExpanded(node.children) + } else { + node.expanded = !!this.nodeExpandedDict[node.path] + } + return node + }) + }, isActiveFile (node) { return node.path === this.currentFilePath },