From af4d4d99a68e5c5c4901e8b89b51094cd6b30aeb Mon Sep 17 00:00:00 2001 From: lijiahang Date: Wed, 24 Jan 2024 19:19:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=91=BD=E4=BB=A4=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 | 2 +- .../controller/CommandSnippetController.http | 2 - .../CommandSnippetGroupController.java | 2 +- .../src/api/asset/command-snippet-group.ts | 52 ++++ orion-ops-ui/src/api/asset/command-snippet.ts | 65 +++++ .../host/terminal/assets/styles/layout.less | 8 +- .../components/layout/empty-recommend.vue | 18 +- .../setting/terminal-action-bar-block.vue | 1 - .../setting/terminal-right-menu-block.vue | 14 +- .../components/snippet/snippet-drawer.vue | 237 +++--------------- .../components/snippet/snippet-group.vue | 54 ++++ .../components/snippet/snippet-item.vue | 95 +++++++ .../host/terminal/types/terminal.const.ts | 3 - 13 files changed, 333 insertions(+), 220 deletions(-) create mode 100644 orion-ops-ui/src/api/asset/command-snippet-group.ts create mode 100644 orion-ops-ui/src/api/asset/command-snippet.ts create mode 100644 orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue create mode 100644 orion-ops-ui/src/views/host/terminal/components/snippet/snippet-item.vue 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 30f55cc0..ef578cb4 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 @@ -49,7 +49,7 @@ public class CodeGenerators { .disableUnitTest() .cache("command:snippet:group:{}", "命令片段分组 ${userId}") .expire(1, TimeUnit.DAYS) - .vue("host", "command-snippet") + .vue("host", "command-snippet-group") .build(), }; // jdbc 配置 - 使用配置文件 diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetController.http b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetController.http index 6c10a419..7fedd72c 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetController.http +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetController.http @@ -6,7 +6,6 @@ Authorization: {{token}} { "groupId": "", "name": "", - "prefix": "", "command": "" } @@ -20,7 +19,6 @@ Authorization: {{token}} "id": "", "groupId": "", "name": "", - "prefix": "", "command": "" } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetGroupController.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetGroupController.java index d87f74de..3f17da43 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetGroupController.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/controller/CommandSnippetGroupController.java @@ -50,7 +50,7 @@ public class CommandSnippetGroupController { } @IgnoreLog(IgnoreLogMode.RET) - @PostMapping("/list") + @GetMapping("/list") @Operation(summary = "查询全部命令片段分组") public List getCommandSnippetGroupList() { return commandSnippetGroupService.getCommandSnippetGroupList(); diff --git a/orion-ops-ui/src/api/asset/command-snippet-group.ts b/orion-ops-ui/src/api/asset/command-snippet-group.ts new file mode 100644 index 00000000..2391ff01 --- /dev/null +++ b/orion-ops-ui/src/api/asset/command-snippet-group.ts @@ -0,0 +1,52 @@ +import axios from 'axios'; + +/** + * 命令片段分组创建请求 + */ +export interface CommandSnippetGroupCreateRequest { + name?: string; +} + +/** + * 命令片段分组更新请求 + */ +export interface CommandSnippetGroupUpdateRequest extends CommandSnippetGroupCreateRequest { + id?: number; +} + +/** + * 命令片段分组查询响应 + */ +export interface CommandSnippetGroupQueryResponse { + id: number; + name: string; +} + +/** + * 创建命令片段分组 + */ +export function createCommandSnippetGroup(request: CommandSnippetGroupCreateRequest) { + return axios.post('/asset/command-snippet-group/create', request); +} + +/** + * 更新命令片段分组 + */ +export function updateCommandSnippetGroup(request: CommandSnippetGroupUpdateRequest) { + return axios.put('/asset/command-snippet-group/update', request); +} + +/** + * 查询全部命令片段分组 + */ +export function getCommandSnippetGroupList() { + return axios.get>('/asset/command-snippet-group/list'); +} + +/** + * 删除命令片段分组 + */ +export function deleteCommandSnippetGroup(id: number) { + return axios.delete('/asset/command-snippet-group/delete', { params: { id } }); +} + diff --git a/orion-ops-ui/src/api/asset/command-snippet.ts b/orion-ops-ui/src/api/asset/command-snippet.ts new file mode 100644 index 00000000..71c93131 --- /dev/null +++ b/orion-ops-ui/src/api/asset/command-snippet.ts @@ -0,0 +1,65 @@ +import type { CommandSnippetGroupQueryResponse } from './command-snippet-group'; +import axios from 'axios'; + +/** + * 命令片段创建请求 + */ +export interface CommandSnippetCreateRequest { + groupId?: number; + name?: string; + command?: string; +} + +/** + * 命令片段更新请求 + */ +export interface CommandSnippetUpdateRequest extends CommandSnippetCreateRequest { + id?: number; +} + +/** + * 命令片段查询响应 + */ +export interface CommandSnippetQueryResponse { + id: number; + groupId: number; + name: string; + command: string; + expand?: boolean; +} + +/** + * 命令片段查询响应 + */ +export interface CommandSnippetWrapperResponse { + groups: Array; + items: Array; +} + +/** + * 创建命令片段 + */ +export function createCommandSnippet(request: CommandSnippetCreateRequest) { + return axios.post('/asset/command-snippet/create', request); +} + +/** + * 更新命令片段 + */ +export function updateCommandSnippet(request: CommandSnippetUpdateRequest) { + return axios.put('/asset/command-snippet/update', request); +} + +/** + * 查询全部命令片段 + */ +export function getCommandSnippetList() { + return axios.get>('/asset/command-snippet/list'); +} + +/** + * 删除命令片段 + */ +export function deleteCommandSnippet(id: number) { + return axios.delete('/asset/command-snippet/delete', { params: { id } }); +} diff --git a/orion-ops-ui/src/views/host/terminal/assets/styles/layout.less b/orion-ops-ui/src/views/host/terminal/assets/styles/layout.less index bb8b3c54..6619e3db 100644 --- a/orion-ops-ui/src/views/host/terminal/assets/styles/layout.less +++ b/orion-ops-ui/src/views/host/terminal/assets/styles/layout.less @@ -5,6 +5,7 @@ body { --color-bg-content: #FEFEFE; --color-sidebar-icon: #737070; --color-sidebar-icon-bg: #D7D8DB; + --color-sidebar-icon-checked: #CBCCCF; --color-sidebar-tooltip-text: rgba(255, 255, 255, .9); --color-sidebar-tooltip-bg: rgb(29, 33, 41); --color-content-text-1: rgba(0, 0, 0, .8); @@ -25,8 +26,9 @@ body[terminal-theme='dark'] { --color-bg-header: #232323; --color-bg-sidebar: #2C2E31; --color-bg-content: #1A1B1C; - --color-sidebar-icon: #C3C8CE; - --color-sidebar-icon-bg: #43444C; + --color-sidebar-icon: #C3C6C9; + --color-sidebar-icon-bg: #3D3E3F; + --color-sidebar-icon-checked: #51525C; --color-sidebar-tooltip-text: rgba(255, 255, 255, .9); --color-sidebar-tooltip-bg: var(--color-sidebar-icon-bg); --color-content-text-1: rgba(255, 255, 255, .8); @@ -214,7 +216,7 @@ body[terminal-theme='dark'] .arco-modal-container { } &.checked-item { - background: var(--color-sidebar-icon-bg); + background: var(--color-sidebar-icon-checked); } &.disabled-item { diff --git a/orion-ops-ui/src/views/host/terminal/components/layout/empty-recommend.vue b/orion-ops-ui/src/views/host/terminal/components/layout/empty-recommend.vue index 30bbfb34..ecf83e39 100644 --- a/orion-ops-ui/src/views/host/terminal/components/layout/empty-recommend.vue +++ b/orion-ops-ui/src/views/host/terminal/components/layout/empty-recommend.vue @@ -99,15 +99,20 @@ diff --git a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue new file mode 100644 index 00000000..d682f1e9 --- /dev/null +++ b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-group.vue @@ -0,0 +1,54 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-item.vue b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-item.vue new file mode 100644 index 00000000..e62afc15 --- /dev/null +++ b/orion-ops-ui/src/views/host/terminal/components/snippet/snippet-item.vue @@ -0,0 +1,95 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/host/terminal/types/terminal.const.ts b/orion-ops-ui/src/views/host/terminal/types/terminal.const.ts index 0dfd8766..1ddbf7a0 100644 --- a/orion-ops-ui/src/views/host/terminal/types/terminal.const.ts +++ b/orion-ops-ui/src/views/host/terminal/types/terminal.const.ts @@ -208,9 +208,6 @@ export const TerminalShortcutItems: Array = [ }, ]; -// 命令片段操作提示 -export const snippetTipsKey = 'snippet:opt'; - // 打开 sshModal key export const openSshModalKey = Symbol();