From c8c947d8a8ed89f1977e803b57366de568609461 Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Tue, 23 Apr 2024 09:15:22 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=9B=9E=E8=BD=A6=E9=87=8D?= =?UTF-8?q?=E8=BF=9E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/store/modules/terminal/index.ts | 26 +++--- .../components/layout/terminal-panel.vue | 10 +- .../new-connection/host-list-modal.vue | 4 +- .../components/sftp/sftp-table-header.vue | 34 ++++++- .../terminal/components/sftp/sftp-table.vue | 13 ++- .../terminal/components/sftp/sftp-view.vue | 20 ++-- .../host/terminal/components/ssh/ssh-view.vue | 7 +- .../host/terminal/handler/sftp-session.ts | 3 + .../host/terminal/handler/ssh-session.ts | 15 +-- .../host/terminal/handler/terminal-channel.ts | 1 - .../handler/terminal-output-processor.ts | 22 +++-- .../handler/terminal-panel-manager.ts | 16 ++-- .../handler/terminal-panel-tab-manager.ts | 91 +++++++++++++++++++ .../handler/terminal-session-manager.ts | 47 +++++----- .../terminal/handler/terminal-tab-manager.ts | 12 +-- .../host/terminal/types/terminal.const.ts | 24 ++--- .../host/terminal/types/terminal.type.ts | 25 ++--- 17 files changed, 247 insertions(+), 123 deletions(-) create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-panel-tab-manager.ts diff --git a/orion-ops-ui/src/store/modules/terminal/index.ts b/orion-ops-ui/src/store/modules/terminal/index.ts index b4316f9f..519c1359 100644 --- a/orion-ops-ui/src/store/modules/terminal/index.ts +++ b/orion-ops-ui/src/store/modules/terminal/index.ts @@ -8,7 +8,7 @@ import type { TerminalShortcutSetting, TerminalState } from './types'; -import type { ISshSession, PanelSessionTab, TerminalPanelTabItem } from '@/views/host/terminal/types/terminal.type'; +import type { ISshSession, PanelSessionTabType, TerminalPanelTabItem } from '@/views/host/terminal/types/terminal.type'; import type { AuthorizedHostQueryResponse } from '@/api/asset/asset-authorized-data'; import { getCurrentAuthorizedHost } from '@/api/asset/asset-authorized-data'; import type { HostQueryResponse } from '@/api/asset/host'; @@ -135,7 +135,7 @@ export default defineStore('terminal', { }, // 打开会话 - openSession(record: HostQueryResponse, type: PanelSessionTab, panelIndex: number = 0) { + openSession(record: HostQueryResponse, type: PanelSessionTabType, panelIndex: number = 0) { // 添加到最近连接 this.hosts.latestHosts = [...new Set([record.id, ...this.hosts.latestHosts])]; // 切换到终端面板页面 @@ -151,8 +151,10 @@ export default defineStore('terminal', { ? Math.max(...seqArr) + 1 : 1; // 打开 tab + const sessionId = nextId(10); this.panelManager.getPanel(panelIndex).openTab({ - key: nextId(10), + key: sessionId, + sessionId, seq: nextSeq, title: `(${nextSeq}) ${record.alias || record.name}`, hostId: record.id, @@ -163,20 +165,18 @@ export default defineStore('terminal', { }); }, - // 重新打开 terminal 会话 - async reOpenTerminal(hostId: number, sessionId: string, panelIndex: number = 0) { - console.log('rec'); - // 添加到最近连接 - this.hosts.latestHosts = [...new Set([hostId, ...this.hosts.latestHosts])]; + // 重新打开会话 + async reOpenSession(sessionId: string, panelIndex: number = 0) { // 切换到终端面板页面 this.tabManager.openTab(TerminalTabs.TERMINAL_PANEL); // 获取当前面板并且分配新的 sessionId const panel = this.panelManager.getPanel(panelIndex); const tab = panel.getTab(sessionId); - const newSessionId = nextId(10); - tab.key = newSessionId; - // 重新打开 ssh - await this.sessionManager.reOpenSsh(sessionId, newSessionId); + const newSessionId = tab.sessionId = nextId(10); + // 添加到最近连接 + this.hosts.latestHosts = [...new Set([tab.hostId, ...this.hosts.latestHosts])]; + // 重新打开会话 + await this.sessionManager.reOpenSession(tab.type, sessionId, newSessionId); }, // 复制并且打开会话 @@ -220,7 +220,7 @@ export default defineStore('terminal', { return; } // 获取会话 - return this.sessionManager.getSession(sessionTab.key); + return this.sessionManager.getSession(sessionTab.sessionId); }, }, diff --git a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-panel.vue b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-panel.vue index 2206cfc8..441988db 100644 --- a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-panel.vue +++ b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-panel.vue @@ -16,9 +16,8 @@ - - + +