🆕 重构监控数据结构

This commit is contained in:
chaoszhu
2024-07-21 23:58:25 +08:00
parent 5b2b776155
commit 655e9bc8af
11 changed files with 132 additions and 169 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
const { readGroupList, writeGroupList, readHostList, writeHostList, randomStr } = require('../utils')
async function getGroupList({ res }) {
const data = await readGroupList()
let data = await readGroupList()
data = data.map(item => {
return { ...item, id: item._id }
})
data?.sort((a, b) => Number(b.index || 0) - Number(a.index || 0))
res.success({ data })
}
+3 -1
View File
@@ -5,9 +5,11 @@ async function getHostList({ res }) {
let data = await readHostList()
data?.sort((a, b) => Number(b.index || 0) - Number(a.index || 0))
data = data.map((item) => {
const isConfig = Boolean(item.username && item.port && (item[item.authType]))
const { username, port, authType, _id: id } = item
const isConfig = Boolean(username && port && (item[authType]))
return {
...item,
id,
isConfig,
password: '',
privateKey: ''