优化: 收藏置顶项背景加重并加服务器一键全连

- 置顶项背景改用 --color-primary-light-1 对齐服务器列表焦点色
- 服务器管理菜单新增一键全连,全连后恢复原焦点
- 修复连 B 失败后焦点回落 A 状态点误染红(改用 per-profile 状态)
This commit is contained in:
lxy
2026-09-28 14:42:22 +08:00
parent b488354369
commit 4746f8cac2
@@ -209,6 +209,9 @@
<div class="settings-item" @click="$emit('openConnectionDialog'); settingsOpen = false"> <div class="settings-item" @click="$emit('openConnectionDialog'); settingsOpen = false">
<icon-plus /> 添加服务器 <icon-plus /> 添加服务器
</div> </div>
<div class="settings-item" @click="connectAllServers">
<icon-link /> 一键全连
</div>
<div class="settings-item" @click="toggleAutoConnect"> <div class="settings-item" @click="toggleAutoConnect">
<icon-check-circle :style="{ opacity: autoConnect ? 1 : 0.3 }" /> <icon-check-circle :style="{ opacity: autoConnect ? 1 : 0.3 }" />
启动时自动连接所有服务器 启动时自动连接所有服务器
@@ -238,7 +241,7 @@ import type { SidebarConfig, FavoriteFile } from '@/types/file-system'
import type { SystemInfo } from '@/api/connection-manager' import type { SystemInfo } from '@/api/connection-manager'
import { connectionManager } from '@/api/connection-manager' import { connectionManager } from '@/api/connection-manager'
import { useConfigStore } from '@/stores/config' 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' import { getFileIcon } from '@/utils/fileUtils'
const configStore = useConfigStore() const configStore = useConfigStore()
@@ -379,6 +382,25 @@ function toggleServerVisibility(id: string) {
localStorage.setItem('desk:hiddenServers', JSON.stringify(hiddenServerIds.value)) 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(() => { connectionManager.onStateChange(() => {
profiles.value = connectionManager.profiles profiles.value = connectionManager.profiles
@@ -541,7 +563,9 @@ function sysInfo(profileId: string): SystemInfo | undefined {
function stateDotClass(profileId: string): string { function stateDotClass(profileId: string): string {
if (profileId === activeId.value) { 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 === 'connected') return 'connected'
if (state === 'connecting') return 'connecting' if (state === 'connecting') return 'connecting'
if (state === 'error') return 'error' if (state === 'error') return 'error'
@@ -602,7 +626,8 @@ function formatBytes(n: number): string {
function stateText(profileId: string): string { function stateText(profileId: string): string {
if (profileId === activeId.value) { if (profileId === activeId.value) {
const s = connectionManager.state // 同 stateDotClass:per-profile 状态不随连接尝试漂移
const s = connectionManager.getProfileState(profileId).state
if (s === 'connected') return '已连接' if (s === 'connected') return '已连接'
if (s === 'connecting') return '连接中...' if (s === 'connecting') return '连接中...'
if (s === 'error') return '连接失败' if (s === 'error') return '连接失败'
@@ -964,7 +989,7 @@ function onSrvCtxVisible(index: number, visible: boolean) {
} }
.sidebar-item-pinned { .sidebar-item-pinned {
background: var(--arcoblue-1); background: var(--color-primary-light-1);
border-radius: 0; border-radius: 0;
} }