From 98b014bb40d9132caf1e82ff710a51214ea97c45 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Fri, 5 Jan 2024 19:49:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=BF=9E=E6=8E=A5=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E5=89=8D=E7=AB=AF=E9=87=8D=E6=9E=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/store/modules/terminal/index.ts | 4 +- .../src/store/modules/terminal/types.ts | 15 ++- .../components/layout/terminal-content.vue | 6 +- .../components/layout/terminal-header.vue | 10 +- .../layout/terminal-left-sidebar.vue | 8 +- .../new-connection/host-list-view.vue | 19 ++- .../components/xterm/terminal-view.vue | 7 +- .../host/terminal/handler/terminal-channel.ts | 102 +++++++++++++++ ...alDispatcher.ts => terminal-dispatcher.ts} | 47 +------ .../handler/terminal-output-processor.ts | 49 ++++++++ .../handler/terminal-session-manager.ts | 58 +++++++++ .../host/terminal/handler/terminal-session.ts | 119 ++++++++++++++++++ .../terminal/handler/terminal-tab-manager.ts | 49 ++++++++ .../host/terminal/types/terminal.const.ts | 6 + .../host/terminal/types/terminal.type.ts | 68 ++++++++++ 15 files changed, 503 insertions(+), 64 deletions(-) create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-channel.ts rename orion-ops-ui/src/views/host/terminal/handler/{TerminalDispatcher.ts => terminal-dispatcher.ts} (81%) create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-output-processor.ts create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-session-manager.ts create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-session.ts create mode 100644 orion-ops-ui/src/views/host/terminal/handler/terminal-tab-manager.ts create mode 100644 orion-ops-ui/src/views/host/terminal/types/terminal.type.ts diff --git a/orion-ops-ui/src/store/modules/terminal/index.ts b/orion-ops-ui/src/store/modules/terminal/index.ts index 8ad38f55..9acada97 100644 --- a/orion-ops-ui/src/store/modules/terminal/index.ts +++ b/orion-ops-ui/src/store/modules/terminal/index.ts @@ -4,7 +4,8 @@ import { getPreference, updatePreference } from '@/api/user/preference'; import { Message } from '@arco-design/web-vue'; import { useDark } from '@vueuse/core'; import { DEFAULT_SCHEMA } from '@/views/host/terminal/types/terminal.theme'; -import TerminalDispatcher from '@/views/host/terminal/handler/TerminalDispatcher'; +import TerminalDispatcher from '@/views/host/terminal/handler/terminal-dispatcher'; +import TerminalTabManager from '@/views/host/terminal/handler/terminal-tab-manager'; // 暗色主题 export const DarkTheme = { @@ -29,6 +30,7 @@ export default defineStore('terminal', { displaySetting: {} as TerminalDisplaySetting, themeSchema: {} as TerminalThemeSchema }, + tabs: new TerminalTabManager(), dispatcher: new TerminalDispatcher() }), diff --git a/orion-ops-ui/src/store/modules/terminal/types.ts b/orion-ops-ui/src/store/modules/terminal/types.ts index b7cae650..83016e58 100644 --- a/orion-ops-ui/src/store/modules/terminal/types.ts +++ b/orion-ops-ui/src/store/modules/terminal/types.ts @@ -4,6 +4,7 @@ import { Terminal } from 'xterm'; export interface TerminalState { isDarkTheme: Ref; preference: TerminalPreference; + tabs: ITerminalTabManager; dispatcher: ITerminalDispatcher; } @@ -66,11 +67,11 @@ export interface TerminalTabItem { [key: string]: unknown; } -// 终端调度器 -export interface ITerminalDispatcher { - // 当前活跃 tab +// 终端 tab 管理器定义 +export interface ITerminalTabManager { + // 当前 tab active: string; - // 所有 tab + // 全部 tab items: Array; // 点击 tab @@ -79,6 +80,12 @@ export interface ITerminalDispatcher { deleteTab: (key: string) => void; // 打开 tab openTab: (tab: TerminalTabItem) => void; + // 清空 + clear: () => void; +} + +// 终端调度器 +export interface ITerminalDispatcher { // 打开终端 openTerminal: (record: any) => void; // 注册终端处理器 diff --git a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-content.vue b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-content.vue index 40199b8d..ae6f4dfe 100644 --- a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-content.vue +++ b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-content.vue @@ -1,8 +1,8 @@