From 95755802eed12e0dcd11f55ec584d3a836be2358 Mon Sep 17 00:00:00 2001 From: "Junpeng.Li" <1635975742@qq.com> Date: Mon, 11 Apr 2022 14:01:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9E=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssh-vue/src/api/fast-cmd.api.js | 85 ++++++ ssh-vue/src/components/fast-cmd/data-form.vue | 97 +++++++ ssh-vue/src/components/fast-cmd/index.vue | 273 ++++++++++++++++++ .../src/components/session-list/data-form.vue | 2 +- ssh-vue/src/views/ssh/index.vue | 74 ++++- ssh-vue/src/views/ssh/top-tool.vue | 37 ++- 6 files changed, 564 insertions(+), 4 deletions(-) create mode 100644 ssh-vue/src/api/fast-cmd.api.js create mode 100644 ssh-vue/src/components/fast-cmd/data-form.vue create mode 100644 ssh-vue/src/components/fast-cmd/index.vue diff --git a/ssh-vue/src/api/fast-cmd.api.js b/ssh-vue/src/api/fast-cmd.api.js new file mode 100644 index 0000000..721db36 --- /dev/null +++ b/ssh-vue/src/api/fast-cmd.api.js @@ -0,0 +1,85 @@ +const API_KEY = 'fast-cmds', SETTING_KEY = 'fast-setting' + +import {v1 as uuidv1} from 'uuid' + +/** + * 获取快速命令列表 + * @returns {{}} + */ +export function findAll() { + const cmds = localStorage.getItem(API_KEY) + if (!cmds) { + return {} + } + + return JSON.parse(cmds) +} + +/** + * 根据ID获取一条快速命令 + * @param id + * @returns {*} + */ +export function getById(id) { + return findAll()[id] +} + +/** + * 添加快速命令 + * @param data + */ +export function addCmd(data) { + const cmds = findAll() + + data.id = uuidv1() + cmds[data.id] = data + + localStorage.setItem(API_KEY, JSON.stringify(cmds)) +} + +/** + * 修改快速命令 + * @param data + */ +export function editCmd(data) { + const cmds = findAll() + cmds[data.id] = data + localStorage.setItem(API_KEY, JSON.stringify(cmds)) +} + +/** + * 删除快速命令 + * @param cmdId + */ +export function removeCmd(cmdId) { + const cmds = findAll() + delete cmds[cmdId] + localStorage.setItem(API_KEY, JSON.stringify(cmds)) +} + +/** + * 获取设置 + * @returns {{mode: string, visible: boolean}|any} + */ +export function getStting() { + const setting = localStorage.getItem(SETTING_KEY) + if (!setting) { + return { + mode: 'single', + visible: false + } + } + + return JSON.parse(setting) +} + +/** + * 添加设置 + * @param key + * @param value + */ +export function setSetting(key, value) { + const setting = getStting() + setting[key] = value + localStorage.setItem(SETTING_KEY, JSON.stringify(setting)) +} diff --git a/ssh-vue/src/components/fast-cmd/data-form.vue b/ssh-vue/src/components/fast-cmd/data-form.vue new file mode 100644 index 0000000..feb3174 --- /dev/null +++ b/ssh-vue/src/components/fast-cmd/data-form.vue @@ -0,0 +1,97 @@ + + + + + + diff --git a/ssh-vue/src/components/fast-cmd/index.vue b/ssh-vue/src/components/fast-cmd/index.vue new file mode 100644 index 0000000..8b86092 --- /dev/null +++ b/ssh-vue/src/components/fast-cmd/index.vue @@ -0,0 +1,273 @@ + + + + + + diff --git a/ssh-vue/src/components/session-list/data-form.vue b/ssh-vue/src/components/session-list/data-form.vue index 6476ed9..4d9c6d0 100644 --- a/ssh-vue/src/components/session-list/data-form.vue +++ b/ssh-vue/src/components/session-list/data-form.vue @@ -1,7 +1,7 @@ @@ -34,7 +35,9 @@ export default { name: "top-tool", - components: {SessionList}, + components: { + SessionList + }, props: { @@ -71,6 +74,25 @@ getStatus() {} } } + }, + + /** + * 快速命令窗口组件 + */ + fastCmdCom: { + type: Object, + default: () => { + return { + // 打开 + open() {}, + + // 关闭 + close() {}, + + // 获取组件的打开状态 + getStatus() {} + } + } } }, @@ -115,6 +137,17 @@ } else { this.compileCom.open() } + }, + + /** + * 打开快速命令窗口 + */ + openFastCmd() { + if (this.fastCmdCom.getStatus()) { + this.fastCmdCom.close() + } else { + this.fastCmdCom.open() + } } }, -- Gitee