From 514c9499e64854a1d7cd5310560d805c3f6b07f7 Mon Sep 17 00:00:00 2001 From: chaoszhu Date: Fri, 19 Jul 2024 10:52:09 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=B0=83=E6=95=B4=E5=88=86?= =?UTF-8?q?=E7=BB=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/controller/host.js | 47 ++++++------ server/app/router/routes.js | 12 +-- web/index.html | 2 +- web/src/api/index.js | 6 +- web/src/components/svg-icon.vue | 7 ++ web/src/views/group/index.vue | 3 +- web/src/views/server/components/host-card.vue | 55 ++++++++++---- web/src/views/server/components/host-form.vue | 30 +++++--- web/src/views/server/index.vue | 76 ++++++++++++------- web/src/views/setting/index.vue | 6 +- 10 files changed, 155 insertions(+), 89 deletions(-) diff --git a/server/app/controller/host.js b/server/app/controller/host.js index f5283bf..d836388 100644 --- a/server/app/controller/host.js +++ b/server/app/controller/host.js @@ -1,30 +1,30 @@ const { readHostList, writeHostList, readSSHRecord, writeSSHRecord } = require('../utils') async function getHostList({ res }) { - console.log('get - host - list') + // console.log('get-host-list') const data = await readHostList() res.success({ data }) } async function saveHost({ res, request }) { - let { body: { host: newHost, name, expired, expiredNotify, group, consoleUrl, remark } } = request - console.log(request) + let { body: { host: newHost, name, index, expired, expiredNotify, group, consoleUrl, remark } } = request + // console.log(request) if (!newHost || !name) return res.fail({ msg: 'missing params: name or host' }) let hostList = await readHostList() if (hostList?.some(({ host }) => host === newHost)) return res.fail({ msg: `主机${ newHost }已存在` }) if (!Array.isArray(hostList)) hostList = [] - hostList.push({ host: newHost, name, expired, expiredNotify, group, consoleUrl, remark }) + hostList.push({ host: newHost, name, index, expired, expiredNotify, group, consoleUrl, remark }) await writeHostList(hostList) res.success() } async function updateHost({ res, request }) { - let { body: { host: newHost, name: newName, oldHost, expired, expiredNotify, group, consoleUrl, remark } } = request + let { body: { host: newHost, name: newName, index, oldHost, expired, expiredNotify, group, consoleUrl, remark } } = request if (!newHost || !newName || !oldHost) return res.fail({ msg: '参数错误' }) let hostList = await readHostList() if (!hostList.some(({ host }) => host === oldHost)) return res.fail({ msg: `主机${ newHost }不存在` }) let targetIdx = hostList.findIndex(({ host }) => host === oldHost) - hostList.splice(targetIdx, 1, { name: newName, host: newHost, expired, expiredNotify, group, consoleUrl, remark }) + hostList.splice(targetIdx, 1, { name: newName, host: newHost, index, expired, expiredNotify, group, consoleUrl, remark }) writeHostList(hostList) res.success() } @@ -46,26 +46,27 @@ async function removeHost({ res, request }) { res.success({ data: `${ host }已移除, ${ flag ? '并移除ssh记录' : '' }` }) } -async function updateHostSort({ res, request }) { - let { body: { list } } = request - if (!list) return res.fail({ msg: '参数错误' }) - let hostList = await readHostList() - if (hostList.length !== list.length) return res.fail({ msg: '失败: host数量不匹配' }) - let sortResult = [] - for (let i = 0; i < list.length; i++) { - const curHost = list[i] - let temp = hostList.find(({ host }) => curHost.host === host) - if (!temp) return res.fail({ msg: `查找失败: ${ curHost.name }` }) - sortResult.push(temp) - } - writeHostList(sortResult) - res.success({ msg: 'success' }) -} +// 原手动排序接口-废弃 +// async function updateHostSort({ res, request }) { +// let { body: { list } } = request +// if (!list) return res.fail({ msg: '参数错误' }) +// let hostList = await readHostList() +// if (hostList.length !== list.length) return res.fail({ msg: '失败: host数量不匹配' }) +// let sortResult = [] +// for (let i = 0; i < list.length; i++) { +// const curHost = list[i] +// let temp = hostList.find(({ host }) => curHost.host === host) +// if (!temp) return res.fail({ msg: `查找失败: ${ curHost.name }` }) +// sortResult.push(temp) +// } +// writeHostList(sortResult) +// res.success({ msg: 'success' }) +// } module.exports = { getHostList, saveHost, updateHost, - removeHost, - updateHostSort + removeHost + // updateHostSort } diff --git a/server/app/router/routes.js b/server/app/router/routes.js index 52d2d49..d8d19d2 100644 --- a/server/app/router/routes.js +++ b/server/app/router/routes.js @@ -1,5 +1,5 @@ const { updateSSH, removeSSH, existSSH, getCommand } = require('../controller/ssh') -const { getHostList, saveHost, updateHost, removeHost, updateHostSort } = require('../controller/host') +const { getHostList, saveHost, updateHost, removeHost } = require('../controller/host') const { login, getpublicKey, updatePwd, getLoginRecord } = require('../controller/user') const { getSupportEmailList, getUserEmailList, updateUserEmailList, removeUserEmail, pushEmail, getNotifyList, updateNotifyList } = require('../controller/notify') const { getGroupList, addGroupList, updateGroupList, removeGroup } = require('../controller/group') @@ -46,12 +46,12 @@ const host = [ method: 'post', path: '/host-remove', controller: removeHost - }, - { - method: 'put', - path: '/host-sort', - controller: updateHostSort } + // { + // method: 'put', + // path: '/host-sort', + // controller: updateHostSort + // } ] const user = [ { diff --git a/web/index.html b/web/index.html index 0f4c10c..58e00dd 100644 --- a/web/index.html +++ b/web/index.html @@ -4,7 +4,7 @@ EasyNode - + diff --git a/web/src/api/index.js b/web/src/api/index.js index 1ed1402..cb724b8 100644 --- a/web/src/api/index.js +++ b/web/src/api/index.js @@ -43,9 +43,9 @@ export default { updatePwd(data) { return axios({ url: '/pwd', method: 'put', data }) }, - updateHostSort(data) { - return axios({ url: '/host-sort', method: 'put', data }) - }, + // updateHostSort(data) { + // return axios({ url: '/host-sort', method: 'put', data }) + // }, getUserEmailList() { return axios({ url: '/user-email', method: 'get' }) }, diff --git a/web/src/components/svg-icon.vue b/web/src/components/svg-icon.vue index 357d559..933806f 100644 --- a/web/src/components/svg-icon.vue +++ b/web/src/components/svg-icon.vue @@ -1,5 +1,6 @@ @@ -8,6 +9,12 @@ export default { name: 'IconSvg', props: { name: { + required: true, + type: String, + default: '' + }, + title: { + required: false, type: String, default: '' } diff --git a/web/src/views/group/index.vue b/web/src/views/group/index.vue index 09de0a0..4ecf255 100644 --- a/web/src/views/group/index.vue +++ b/web/src/views/group/index.vue @@ -7,6 +7,7 @@ :inline="true" :hide-required-asterisk="true" label-suffix=":" + :show-message="false" > { $api.getGroupList() .then(({ data }) => { groupList.value = data - groupForm.index = data.length + // groupForm.index = data.length }) .finally(() => loading.value = false) } diff --git a/web/src/views/server/components/host-card.vue b/web/src/views/server/components/host-card.vue index 2ce597c..285b85c 100644 --- a/web/src/views/server/components/host-card.vue +++ b/web/src/views/server/components/host-card.vue @@ -132,20 +132,32 @@ ↓ {{ $tools.formatNetSpeed(netstatInfo.netTotal?.inputMb) || 0 }} -
- - - 功能 - - +
+ + + +
@@ -155,6 +167,7 @@ diff --git a/web/src/views/setting/index.vue b/web/src/views/setting/index.vue index 6f34541..5807959 100644 --- a/web/src/views/setting/index.vue +++ b/web/src/views/setting/index.vue @@ -10,9 +10,9 @@ - + @@ -27,7 +27,7 @@ import { computed } from 'vue' import NotifyList from './components/notify-list.vue' import EmailList from './components/email-list.vue' -import Sort from './components/sort.vue' +// import Sort from './components/sort.vue' import Record from './components/record.vue' // import Group from './components/group.vue' import Password from './components/password.vue'