From ac2376842a37ca621af2f6ac333b2a4099c5880c Mon Sep 17 00:00:00 2001 From: lijiahang Date: Thu, 25 Jan 2024 19:08:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AD=98=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=89=87=E6=AE=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/generator/CodeGenerators.java | 7 +- .../src/components/view/editor/index.vue | 2 +- .../command-snippet-form-drawer.vue | 152 ++++++++++++++++++ .../components/command-snippet-group.vue} | 6 +- .../components/command-snippet-item.vue} | 18 ++- .../command-snippet-list-drawer.vue} | 76 +++++++-- .../views/host/command-snippet/types/const.ts | 5 + .../host/command-snippet/types/form.rules.ts | 24 +++ .../layout/terminal-right-sidebar.vue | 8 +- .../new-connection/host-list-view.vue | 4 +- .../handler/terminal-session-handler.ts | 11 +- .../host/terminal/types/terminal.type.ts | 4 +- 12 files changed, 281 insertions(+), 36 deletions(-) create mode 100644 orion-ops-ui/src/views/host/command-snippet/components/command-snippet-form-drawer.vue rename orion-ops-ui/src/views/host/{terminal/components/snippet/snippet-group.vue => command-snippet/components/command-snippet-group.vue} (90%) rename orion-ops-ui/src/views/host/{terminal/components/snippet/snippet-item.vue => command-snippet/components/command-snippet-item.vue} (92%) rename orion-ops-ui/src/views/host/{terminal/components/snippet/snippet-drawer.vue => command-snippet/components/command-snippet-list-drawer.vue} (67%) create mode 100644 orion-ops-ui/src/views/host/command-snippet/types/const.ts create mode 100644 orion-ops-ui/src/views/host/command-snippet/types/form.rules.ts diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java index ef578cb4..450262ed 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java @@ -45,11 +45,12 @@ public class CodeGenerators { // .color("blue", "gray", "red", "green", "white") // .valueUseFields() // .build(), - Template.create("command_snippet_group", "命令片段分组", "command") + Template.create("command_snippet", "命令片段", "command") .disableUnitTest() - .cache("command:snippet:group:{}", "命令片段分组 ${userId}") + .cache("command:snippet:group:{}", "命令片段 ${userId}") .expire(1, TimeUnit.DAYS) - .vue("host", "command-snippet-group") + .vue("asset", "command-snippet") + .enableDrawerForm() .build(), }; // jdbc 配置 - 使用配置文件 diff --git a/orion-ops-ui/src/components/view/editor/index.vue b/orion-ops-ui/src/components/view/editor/index.vue index bc09b9cb..8d629092 100644 --- a/orion-ops-ui/src/components/view/editor/index.vue +++ b/orion-ops-ui/src/components/view/editor/index.vue @@ -11,7 +11,7 @@ diff --git a/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-form-drawer.vue b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-form-drawer.vue new file mode 100644 index 00000000..827e7631 --- /dev/null +++ b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-form-drawer.vue @@ -0,0 +1,152 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-group.vue similarity index 90% rename from orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue rename to orion-ops-ui/src/views/host/command-snippet/components/command-snippet-group.vue index ad622246..3585baea 100644 --- a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue +++ b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-group.vue @@ -10,7 +10,7 @@ @@ -21,14 +21,14 @@ @@ -116,6 +116,8 @@ import { useTerminalStore } from '@/store'; import { useDebounceFn } from '@vueuse/core'; import useCopy from '@/hooks/copy'; + import { inject } from 'vue'; + import { openUpdateSnippetKey, removeSnippetKey } from '../types/const'; const props = defineProps<{ item: CommandSnippetQueryResponse @@ -124,10 +126,16 @@ const { copy } = useCopy(); const { getCurrentTerminalSession } = useTerminalStore(); - // TODO 修改 删除 拼接有bug + // TODO 多行拼接有bug let clickCount = 0; + // 修改 + const openUpdateSnippet = inject<(item: CommandSnippetQueryResponse) => void>(openUpdateSnippetKey); + + // 删除 + const removeSnippet = inject<(id: number) => void>(removeSnippetKey); + // 点击命令 const clickItem = () => { if (++clickCount == 2) { @@ -161,7 +169,7 @@ // 执行 const exec = () => { - write(props.item.command + '\n'); + write(props.item.command + '\r\n'); }; // 写入命令 diff --git a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-list-drawer.vue similarity index 67% rename from orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue rename to orion-ops-ui/src/views/host/command-snippet/components/command-snippet-list-drawer.vue index 045fdc72..6fcd67a2 100644 --- a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-drawer.vue +++ b/orion-ops-ui/src/views/host/command-snippet/components/command-snippet-list-drawer.vue @@ -15,7 +15,9 @@
- + @@ -43,40 +45,45 @@
- +
+ +