perf: add expand/collapse group folder with double click

This commit is contained in:
tiny-craft 2023-08-23 16:51:55 +08:00
parent 1702246609
commit 22f71e4676
1 changed files with 12 additions and 0 deletions

View File

@ -216,11 +216,23 @@ const removeGroup = async (name) => {
}) })
} }
const expandKey = (key) => {
const idx = indexOf(expandedKeys.value, key)
if (idx === -1) {
expandedKeys.value.push(key)
} else {
expandedKeys.value.splice(idx, 1)
}
}
const nodeProps = ({ option }) => { const nodeProps = ({ option }) => {
return { return {
onDblclick: async () => { onDblclick: async () => {
if (option.type === ConnectionType.Server) { if (option.type === ConnectionType.Server) {
openConnection(option.name).then(() => {}) openConnection(option.name).then(() => {})
} else if (option.type === ConnectionType.Group) {
// toggle expand
nextTick().then(() => expandKey(option.key))
} }
}, },
onContextmenu(e) { onContextmenu(e) {