mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
打开上一次文件支持仓库
This commit is contained in:
@@ -23,10 +23,9 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.current = this.getRepo()
|
||||
this.fetchRepositories()
|
||||
},
|
||||
mounted () {
|
||||
},
|
||||
beforeDestroy () {
|
||||
},
|
||||
methods: {
|
||||
@@ -34,19 +33,27 @@ export default {
|
||||
file.fetchRepositories(data => {
|
||||
this.list = data
|
||||
const keys = Object.keys(data)
|
||||
if (keys.length > 0) {
|
||||
|
||||
if (keys.length > 0 && !keys.includes(this.current)) {
|
||||
this.choose(keys[0])
|
||||
}
|
||||
})
|
||||
},
|
||||
choose (name) {
|
||||
this.current = name
|
||||
},
|
||||
storeRepo (name) {
|
||||
window.localStorage['repository'] = name
|
||||
},
|
||||
getRepo () {
|
||||
return window.localStorage['repository'] || null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
current (val) {
|
||||
if (val) {
|
||||
this.$bus.emit('switch-repository', val)
|
||||
this.storeRepo(this.current)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -51,6 +51,7 @@ export default {
|
||||
if (repo) {
|
||||
this.repo = repo
|
||||
this.tree = null
|
||||
this.file = null
|
||||
}
|
||||
|
||||
File.tree(this.repo, tree => {
|
||||
|
||||
@@ -42,14 +42,20 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.$bus.on('editor-ready', () => {
|
||||
this.chooseFile(this.getSelectedFilePath())
|
||||
})
|
||||
this.$bus.on('choose-file', file => {
|
||||
this.chooseFile(file.path)
|
||||
})
|
||||
this.$bus.on('editor-ready', this.handleEditorReady)
|
||||
this.$bus.on('choose-file', this.handleChooseFile)
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.$bus.off('editor-ready', this.handleEditorReady)
|
||||
this.$bus.off('choose-file', this.handleChooseFile)
|
||||
},
|
||||
methods: {
|
||||
handleEditorReady () {
|
||||
this.chooseFile(this.getSelectedFilePath())
|
||||
},
|
||||
handleChooseFile (file) {
|
||||
this.chooseFile(file.path)
|
||||
},
|
||||
chooseFile (filePath) {
|
||||
if (this.item.type === 'dir' && filePath.startsWith(this.item.path)) {
|
||||
this.$refs.dir.open = true
|
||||
|
||||
Reference in New Issue
Block a user