Skip to content

Commit 838b344

Browse files
committed
feat: application feature navigation.
1 parent f966744 commit 838b344

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

frontend/src/views/Dashboard.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
<el-tree
5858
:data="serverTree"
5959
node-key="id"
60-
default-expand-all
60+
:default-expanded-keys="expandedKeys"
6161
:expand-on-click-node="false"
6262
@node-click="handleServerClick"
63+
@node-expand="handleNodeExpand"
64+
@node-collapse="handleNodeCollapse"
6365
>
6466
<template #default="{ node, data }">
6567
<div class="tree-node">
@@ -182,6 +184,26 @@ const showEditServerDialog = ref(false)
182184
const editingServerId = ref(null)
183185
const editingServerName = ref('')
184186
187+
// 分组展开状态持久化 (sessionStorage)
188+
const EXPANDED_KEYS_STORAGE_KEY = 'webssh_dashboard_expanded_keys'
189+
const expandedKeys = ref(JSON.parse(sessionStorage.getItem(EXPANDED_KEYS_STORAGE_KEY) || '[]'))
190+
191+
// 监听分组展开
192+
const handleNodeExpand = (data) => {
193+
if (data.type === 'group' && !expandedKeys.value.includes(data.id)) {
194+
expandedKeys.value.push(data.id)
195+
sessionStorage.setItem(EXPANDED_KEYS_STORAGE_KEY, JSON.stringify(expandedKeys.value))
196+
}
197+
}
198+
199+
// 监听分组折叠
200+
const handleNodeCollapse = (data) => {
201+
if (data.type === 'group') {
202+
expandedKeys.value = expandedKeys.value.filter(id => id !== data.id)
203+
sessionStorage.setItem(EXPANDED_KEYS_STORAGE_KEY, JSON.stringify(expandedKeys.value))
204+
}
205+
}
206+
185207
// 计算服务器树形数据
186208
const serverTree = computed(() => {
187209
const groups = {}

0 commit comments

Comments
 (0)