✨ feat(workspace): 增强连接管理与终端状态展示
- 为连接管理页补充多级标签树、列头排序和行级更多菜单
- 支持同一 SSH 连接打开多个终端并显示终端序号
- 补充状态监控的内存与磁盘详情字段
---
✨ feat(workspace): enhance connection management and terminal status visibility
- add multi-level tag tree, sortable columns, and row-level more menu
- support multiple terminals per SSH connection with terminal indices
- extend status monitor with memory and disk detail fields
This commit is contained in:
@@ -21,6 +21,18 @@ const findConnectionInfo = (connectionId: number | string, connectionsStore: Ret
|
||||
return connectionsStore.connections.find(c => c.id === Number(connectionId));
|
||||
};
|
||||
|
||||
const getNextTerminalIndex = (connectionId: string): number => {
|
||||
let maxTerminalIndex = 0;
|
||||
|
||||
sessions.value.forEach((session) => {
|
||||
if (session.connectionId === connectionId) {
|
||||
maxTerminalIndex = Math.max(maxTerminalIndex, session.terminalIndex || 0);
|
||||
}
|
||||
});
|
||||
|
||||
return maxTerminalIndex + 1;
|
||||
};
|
||||
|
||||
// --- Actions ---
|
||||
export const openNewSession = (
|
||||
connectionOrId: ConnectionInfo | number | string,
|
||||
@@ -51,6 +63,7 @@ export const openNewSession = (
|
||||
|
||||
const newSessionId = existingSessionId || generateSessionId();
|
||||
const dbConnId = String(connInfo.id); // connInfo is now guaranteed to be defined here
|
||||
const terminalIndex = getNextTerminalIndex(dbConnId);
|
||||
|
||||
// 1. 创建管理器实例
|
||||
const isResume = !!existingSessionId; // 如果提供了 existingSessionId,则为恢复流程
|
||||
@@ -60,6 +73,7 @@ export const openNewSession = (
|
||||
sessionId: newSessionId,
|
||||
connectionId: dbConnId,
|
||||
connectionName: connInfo.name || connInfo.host,
|
||||
terminalIndex,
|
||||
editorTabs: ref([]),
|
||||
activeEditorTabId: ref(null),
|
||||
commandInputContent: ref(''),
|
||||
@@ -115,7 +129,7 @@ export const openNewSession = (
|
||||
newSessionsMap.set(newSessionId, newSession);
|
||||
sessions.value = newSessionsMap;
|
||||
activeSessionId.value = newSessionId;
|
||||
console.log(`[SessionActions] 已创建新会话实例: ${newSessionId} for connection ${dbConnId}`);
|
||||
console.log(`[SessionActions] 已创建新会话实例: ${newSessionId} for connection ${dbConnId} (terminal #${terminalIndex})`);
|
||||
|
||||
// +++ 在连接前设置 ssh:connected 处理器以更新 sessionId +++
|
||||
const originalFrontendSessionIdForHandler = newSessionId; // 捕获初始ID给闭包
|
||||
@@ -320,4 +334,4 @@ export const cleanupAllSessions = () => {
|
||||
sessions.value = newSessionsMap;
|
||||
}
|
||||
activeSessionId.value = null;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user