修复选择文件不展开文件树

This commit is contained in:
purocean
2018-07-29 20:21:49 +08:00
parent 495abdaaad
commit cd4ee20c42
3 changed files with 14 additions and 9 deletions
+4 -4
View File
@@ -74,10 +74,10 @@ export default {
this.updateSelected(this.list[index])
},
chooseItem (item = null) {
if (item) {
this.$emit('choose-item', item)
} else if (this.selected) {
this.$emit('choose-item', this.selected)
const file = item || this.selected
if (file) {
this.$emit('choose-file', file)
this.$bus.emit('choose-file', file)
}
}
},
+1 -1
View File
@@ -11,7 +11,7 @@
@delete="onDelete" />
<transition name="fade">
<div v-if="showFilter" class="filter-wrapper" @click="showFilter = false">
<XFilter @choose-item="f => { file = f; showFilter = false }" :files="files" />
<XFilter @choose-file="f => { showFilter = false }" :files="files" />
</div>
</transition>
</aside>
+9 -4
View File
@@ -43,15 +43,20 @@ export default {
},
mounted () {
this.$bus.on('editor-ready', () => {
const filePath = this.getSelectedFilePath()
this.chooseFile(this.getSelectedFilePath())
})
this.$bus.on('choose-file', file => {
this.chooseFile(file.path)
})
},
methods: {
chooseFile (filePath) {
if (this.item.type === 'dir' && filePath.startsWith(this.item.path)) {
this.$refs.dir.open = true
} else if (filePath === this.item.path) {
this.select(this.item)
}
})
},
methods: {
},
select (f) {
if (f.name.endsWith('.md')) {
this.$nextTick(() => {