From 3480182473d164e6cf036d27812c67e04b4e4ee6 Mon Sep 17 00:00:00 2001 From: KOMATA <20227709+HynoR@users.noreply.github.com> Date: Thu, 23 Oct 2025 17:20:16 +0800 Subject: [PATCH] feat: Refactor quick command function, turn cascader into palette (#10732) --- .../src/views/terminal/terminal/index.vue | 243 ++++++++++++++---- 1 file changed, 200 insertions(+), 43 deletions(-) diff --git a/frontend/src/views/terminal/terminal/index.vue b/frontend/src/views/terminal/terminal/index.vue index 802e20470..30a51b2ff 100644 --- a/frontend/src/views/terminal/terminal/index.vue +++ b/frontend/src/views/terminal/terminal/index.vue @@ -32,7 +32,7 @@ -
- +
- - - - - + + + +
+ +
+ + {{ + cmd.label.length > 8 ? cmd.label.substring(0, 8) + '...' : cmd.label + }} + + + +
+
+ {{ cmd.label }} +
+
{{ cmd.value }}
+
+
+
+
+
+
+
+
+ + +
+ + {{ $t('terminal.quickCommand') }} + + + + + +
@@ -82,10 +148,10 @@ {{ $t('terminal.localhost') }}
-
+
@@ -185,6 +251,8 @@ const terminalTabs = ref([]) as any; let tabIndex = 0; const commandTree = ref(); +const cmdPanelVisible = ref(false); +const activeGroupTab = ref(''); let quickCmd = ref(); let batchVal = ref(); let isBatch = ref(false); @@ -239,6 +307,9 @@ const cleanTimer = () => { const loadHeight = () => { return globalStore.openMenuTabs ? '230px' : '190px'; }; +const loadHeightWithPanel = () => { + return globalStore.openMenuTabs ? '470px' : '430px'; +}; const loadEmptyHeight = () => { return globalStore.openMenuTabs ? '201px' : '156px'; }; @@ -288,26 +359,23 @@ const loadCommandTree = async () => { item.label = i18n.global.t('commons.table.default'); } } + if (commandTree.value.length > 0) { + activeGroupTab.value = commandTree.value[0].value; + } }; -function quickInput(val: Array) { - if (val.length < 1) { - return; - } +const executeCommand = (command: string) => { if (!ctx) { return; } - quickCmd.value = val[val.length - 1]; if (isBatch.value) { for (const tab of terminalTabs.value) { - ctx.refs[`t-${tab.index}`] && ctx.refs[`t-${tab.index}`][0].sendMsg(quickCmd.value + '\n'); + ctx.refs[`t-${tab.index}`] && ctx.refs[`t-${tab.index}`][0].sendMsg(command + '\n'); } - quickCmd.value = ''; - return; + } else { + ctx.refs[`t-${terminalValue.value}`] && ctx.refs[`t-${terminalValue.value}`][0].sendMsg(command + '\n'); } - ctx.refs[`t-${terminalValue.value}`] && ctx.refs[`t-${terminalValue.value}`][0].sendMsg(quickCmd.value + '\n'); - quickCmd.value = ''; -} +}; function batchInput() { if (batchVal.value === '' || !ctx) { @@ -494,22 +562,111 @@ onMounted(() => { font-size: 32px; font-weight: 600; } -.fullScreen { - background-color: transparent; - border: none; - position: absolute; - right: 50px; - font-weight: 600; - font-size: 14px; -} .el-tabs--top.el-tabs--card > .el-tabs__header .el-tabs__item:last-child { padding-right: 0px; } .el-input__wrapper { border-radius: 50px; } -.el-input-group__prepend { - border-top-left-radius: 50px; - border-bottom-left-radius: 50px; + +:deep(.el-textarea__inner) { + border-radius: 4px; + resize: none; + min-height: 32px; + transition: height 0.2s ease; +} + +.command-tabs { + :deep(.el-tabs__header) { + margin-bottom: 0; + background-color: var(--el-bg-color); + } + :deep(.el-tabs__content) { + height: 180px; + overflow-y: auto; + overflow-x: hidden; + background-color: var(--el-bg-color); + } + :deep(.el-tabs__item) { + min-width: 80px; + max-width: 110px; + text-align: center; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + padding: 0 8px; + } +} +.group-tab-label { + width: 90px; + display: inline-block; + text-align: center; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 14px; +} + +.command-tag { + cursor: pointer; + height: auto; + padding: 8px 12px; + transition: all 0.3s; + border-radius: 4px; + white-space: nowrap; + border: 1px solid transparent; + + &:hover { + border-color: var(--el-color-primary); + } +} + +.command-tag-name { + font-weight: 500; + font-size: 13px; + flex: 1; + text-align: left; +} + +.command-preview-icon { + font-size: 14px; + opacity: 0.6; + transition: opacity 0.3s; + cursor: help; + flex-shrink: 0; + display: flex; + align-items: center; + + &:hover { + opacity: 1; + } +} + +.command-preview { + .command-preview-name { + font-size: 13px; + margin-bottom: 6px; + color: var(--el-text-color-primary); + word-break: break-word; + } + + .command-preview-value { + font-size: 12px; + font-family: monospace; + padding: 8px; + background-color: var(--el-fill-color-light); + border-radius: 4px; + color: var(--el-text-color-regular); + word-break: break-all; + white-space: pre-wrap; + } +} + +.command-tag-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + display: inline-block; }