fix: eslint for vue components
This commit is contained in:
@@ -15,68 +15,70 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'tree',
|
||||
data () {
|
||||
return {
|
||||
tree: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetch (basePath) {
|
||||
let self = this
|
||||
self.$store.dispatch('startLoading')
|
||||
self.$nextTick(() => {
|
||||
socket.emit('treeFetch', { basePath }, (data) => {
|
||||
if (self.tree.length > 0) {
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = true
|
||||
self._.find(branch.pages, { _id: basePath }).isActive = true
|
||||
}
|
||||
self.tree.push({
|
||||
hasChildren: false,
|
||||
pages: data
|
||||
})
|
||||
self.$store.dispatch('stopLoading')
|
||||
})
|
||||
})
|
||||
},
|
||||
goto (entryPath) {
|
||||
window.location.assign(siteRoot + '/' + entryPath)
|
||||
},
|
||||
unfold (entryPath) {
|
||||
let self = this
|
||||
let lastIndex = 0
|
||||
self._.forEach(self.tree, branch => {
|
||||
lastIndex++
|
||||
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
|
||||
return false
|
||||
}
|
||||
})
|
||||
self.tree = self._.slice(self.tree, 0, lastIndex)
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = false
|
||||
branch.pages.forEach(page => {
|
||||
page.isActive = false
|
||||
})
|
||||
},
|
||||
mainAction (page) {
|
||||
let self = this
|
||||
if (page.isActive) {
|
||||
self.unfold(page._id)
|
||||
} else if (page.isDirectory) {
|
||||
self.fetch(page._id)
|
||||
} else {
|
||||
self.goto(page._id)
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
let basePath = window.location.pathname.slice(0, -4)
|
||||
if (basePath.length > 1) {
|
||||
basePath = basePath.slice(1)
|
||||
}
|
||||
this.fetch(basePath)
|
||||
/* global socket, siteRoot */
|
||||
|
||||
export default {
|
||||
name: 'tree',
|
||||
data () {
|
||||
return {
|
||||
tree: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetch (basePath) {
|
||||
let self = this
|
||||
self.$store.dispatch('startLoading')
|
||||
self.$nextTick(() => {
|
||||
socket.emit('treeFetch', { basePath }, (data) => {
|
||||
if (self.tree.length > 0) {
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = true
|
||||
self._.find(branch.pages, { _id: basePath }).isActive = true
|
||||
}
|
||||
self.tree.push({
|
||||
hasChildren: false,
|
||||
pages: data
|
||||
})
|
||||
self.$store.dispatch('stopLoading')
|
||||
})
|
||||
})
|
||||
},
|
||||
goto (entryPath) {
|
||||
window.location.assign(siteRoot + '/' + entryPath)
|
||||
},
|
||||
unfold (entryPath) {
|
||||
let self = this
|
||||
let lastIndex = 0
|
||||
self._.forEach(self.tree, branch => {
|
||||
lastIndex++
|
||||
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
|
||||
return false
|
||||
}
|
||||
})
|
||||
self.tree = self._.slice(self.tree, 0, lastIndex)
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = false
|
||||
branch.pages.forEach(page => {
|
||||
page.isActive = false
|
||||
})
|
||||
},
|
||||
mainAction (page) {
|
||||
let self = this
|
||||
if (page.isActive) {
|
||||
self.unfold(page._id)
|
||||
} else if (page.isDirectory) {
|
||||
self.fetch(page._id)
|
||||
} else {
|
||||
self.goto(page._id)
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
let basePath = window.location.pathname.slice(0, -4)
|
||||
if (basePath.length > 1) {
|
||||
basePath = basePath.slice(1)
|
||||
}
|
||||
this.fetch(basePath)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user