diff --git a/frontend/src/components/FileSystem/components/Sidebar.vue b/frontend/src/components/FileSystem/components/Sidebar.vue index 710e980..0197cbb 100644 --- a/frontend/src/components/FileSystem/components/Sidebar.vue +++ b/frontend/src/components/FileSystem/components/Sidebar.vue @@ -209,6 +209,9 @@
添加服务器
+
+ 一键全连 +
启动时自动连接所有服务器 @@ -238,7 +241,7 @@ import type { SidebarConfig, FavoriteFile } from '@/types/file-system' import type { SystemInfo } from '@/api/connection-manager' import { connectionManager } from '@/api/connection-manager' import { useConfigStore } from '@/stores/config' -import { IconStar, IconClose, IconPushpin, IconEdit, IconMore, IconDown, IconRight, IconStorage, IconComputer, IconDesktop, IconPlus, IconCheckCircle } from '@arco-design/web-vue/es/icon' +import { IconStar, IconClose, IconPushpin, IconEdit, IconMore, IconDown, IconRight, IconStorage, IconComputer, IconDesktop, IconPlus, IconCheckCircle, IconLink } from '@arco-design/web-vue/es/icon' import { getFileIcon } from '@/utils/fileUtils' const configStore = useConfigStore() @@ -379,6 +382,25 @@ function toggleServerVisibility(id: string) { localStorage.setItem('desk:hiddenServers', JSON.stringify(hiddenServerIds.value)) } +// 一键全连:并发连接所有可见的非本地服务器(连接池模式,已连的探测复用), +// 全部落地后恢复原焦点,不打扰当前视图 +const connectingAll = ref(false) +async function connectAllServers() { + if (connectingAll.value) return + settingsOpen.value = false + connectingAll.value = true + const prevActive = activeId.value + try { + const targets = visibleProfiles.value.filter(p => p.type !== 'local') + await Promise.allSettled(targets.map(p => connectionManager.connect(p.id))) + if (prevActive && profiles.value.some(p => p.id === prevActive)) { + await connectionManager.connect(prevActive).catch(() => {}) + } + } finally { + connectingAll.value = false + } +} + // 监听连接变化 + 系统信息变化 connectionManager.onStateChange(() => { profiles.value = connectionManager.profiles @@ -541,7 +563,9 @@ function sysInfo(profileId: string): SystemInfo | undefined { function stateDotClass(profileId: string): string { if (profileId === activeId.value) { - const state = connectionManager.state + // 用 per-profile 状态而非全局 state:全局 state 只描述最近一次连接尝试, + // 连 B 失败后全局停在 error,焦点回落 A 会把 A 误染红 + const state = connectionManager.getProfileState(profileId).state if (state === 'connected') return 'connected' if (state === 'connecting') return 'connecting' if (state === 'error') return 'error' @@ -602,7 +626,8 @@ function formatBytes(n: number): string { function stateText(profileId: string): string { if (profileId === activeId.value) { - const s = connectionManager.state + // 同 stateDotClass:per-profile 状态不随连接尝试漂移 + const s = connectionManager.getProfileState(profileId).state if (s === 'connected') return '已连接' if (s === 'connecting') return '连接中...' if (s === 'error') return '连接失败' @@ -964,7 +989,7 @@ function onSrvCtxVisible(index: number, visible: boolean) { } .sidebar-item-pinned { - background: var(--arcoblue-1); + background: var(--color-primary-light-1); border-radius: 0; }