From 3011ecee9eb20acff0453704a0d276247c9be54b Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Thu, 25 Jan 2024 00:04:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9F=A5=E8=AF=A2=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=88=86=E7=BB=84.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orion-ops-ui/src/api/asset/command-snippet.ts | 2 +- .../asset/host-group/host-group-tree.vue | 10 +- .../src/store/modules/terminal/index.ts | 15 ++- .../layout/terminal-right-sidebar.vue | 13 +-- .../setting/terminal-shortcut-keys-block.vue | 3 +- .../components/snippet/snippet-drawer.vue | 40 ++++++-- .../components/snippet/snippet-item.vue | 98 +++++++++++++++++-- 7 files changed, 149 insertions(+), 32 deletions(-) diff --git a/orion-ops-ui/src/api/asset/command-snippet.ts b/orion-ops-ui/src/api/asset/command-snippet.ts index 4325a90f..80ffd328 100644 --- a/orion-ops-ui/src/api/asset/command-snippet.ts +++ b/orion-ops-ui/src/api/asset/command-snippet.ts @@ -29,7 +29,7 @@ export interface CommandSnippetQueryResponse extends CommandSnippetQueryResponse export interface CommandSnippetQueryResponseExtra { visible: boolean; - expand: boolean; + expand?: boolean; } /** diff --git a/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue b/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue index ee47ed37..01a21501 100644 --- a/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue +++ b/orion-ops-ui/src/components/asset/host-group/host-group-tree.vue @@ -74,10 +74,10 @@ -
- 暂无数据 + + 暂无数据
点击上方 '' 添加一个分组吧~ -
+ @@ -214,8 +214,8 @@ // 保存节点 const saveNode = async (node: TreeNodeData) => { - const key = node.key - const newTitle = node.title + const key = node.key; + const newTitle = node.title; node.modCount = (node.modCount || 0) + 1; if (node.modCount != 1) { return; diff --git a/orion-ops-ui/src/store/modules/terminal/index.ts b/orion-ops-ui/src/store/modules/terminal/index.ts index 31451696..bdd65705 100644 --- a/orion-ops-ui/src/store/modules/terminal/index.ts +++ b/orion-ops-ui/src/store/modules/terminal/index.ts @@ -159,7 +159,20 @@ export default defineStore('terminal', { if (host) { this.openTerminal(host); } - } + }, + + // 获取当前终端会话 + getCurrentTerminalSession(tips: boolean = true) { + const tab = this.tabManager.getCurrentTab(); + if (!tab || tab.type !== TerminalTabType.TERMINAL) { + if (tips) { + Message.warning('请切换到终端标签页'); + } + return; + } + // 获取处理器并截图 + return this.sessionManager.getSession(tab.key); + }, }, diff --git a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-right-sidebar.vue b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-right-sidebar.vue index 88066dd4..54c5975c 100644 --- a/orion-ops-ui/src/views/host/terminal/components/layout/terminal-right-sidebar.vue +++ b/orion-ops-ui/src/views/host/terminal/components/layout/terminal-right-sidebar.vue @@ -30,7 +30,7 @@ const emits = defineEmits(['openSftp', 'openTransfer']); - const { tabManager, sessionManager } = useTerminalStore(); + const { getCurrentTerminalSession } = useTerminalStore(); const snippetRef = ref(); @@ -67,15 +67,10 @@ // 终端截屏 const screenshot = () => { - const tab = tabManager.getCurrentTab(); - if (!tab || tab.type !== TerminalTabType.TERMINAL) { - Message.warning('请切换到终端标签页'); - return; + const handler = getCurrentTerminalSession()?.handler; + if (handler && handler.enabledStatus('screenshot')) { + handler.screenshot(); } - // 获取处理器并截图 - sessionManager.getSession(tab.key) - ?.handler - ?.screenshot(); }; diff --git a/orion-ops-ui/src/views/host/terminal/components/setting/terminal-shortcut-keys-block.vue b/orion-ops-ui/src/views/host/terminal/components/setting/terminal-shortcut-keys-block.vue index 5f528085..652d0f48 100644 --- a/orion-ops-ui/src/views/host/terminal/components/setting/terminal-shortcut-keys-block.vue +++ b/orion-ops-ui/src/views/host/terminal/components/setting/terminal-shortcut-keys-block.vue @@ -17,7 +17,7 @@ import type { TerminalShortcutKeyEditable } from '@/store/modules/terminal/types'; + import type { VNodeRef } from 'vue'; import { nextTick } from 'vue'; defineProps<{ diff --git a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue index 142c888e..1fa20adb 100644 --- a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue +++ b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue @@ -1,7 +1,8 @@ - + @@ -56,9 +71,11 @@ import { getCommandSnippetList } from '@/api/asset/command-snippet'; import SnippetItem from './snippet-item.vue'; import SnippetGroup from './snippet-group.vue'; + import { useTerminalStore } from '@/store'; const { loading, setLoading } = useLoading(); const { visible, setVisible } = useVisible(); + const { getCurrentTerminalSession } = useTerminalStore(); const filterValue = ref(); const snippet = ref(); @@ -70,6 +87,8 @@ await fetchData(); }; + // TODO 新增 + defineExpose({ open }); // 加载数据 @@ -106,13 +125,18 @@ }); }; - onMounted(() => { - open(); - }); + // 关闭 + const onClose = () => { + setVisible(false); + // 聚焦终端 + getCurrentTerminalSession(false)?.focus(); + }; + + // fixme + onMounted(open); -