@@ -182,7 +183,7 @@ let timeRemaining = ref(0)
const isClient = ref(false)
let formData = reactive({
- hosts: [],
+ hostIds: [],
command: '',
timeout: 120
})
@@ -206,13 +207,13 @@ const expandRows = computed(() => {
const rules = computed(() => {
return {
- hosts: { required: true, trigger: 'change' },
+ hostIds: { required: true, trigger: 'change' },
command: { required: true, trigger: 'change' },
timeout: { required: true, type: 'number', trigger: 'change' }
}
})
-watch(() => formData.hosts, (val) => {
+watch(() => formData.hostIds, (val) => {
if (val.length === 0) {
checkAll.value = false
indeterminate.value = false
@@ -224,7 +225,7 @@ watch(() => formData.hosts, (val) => {
}
})
-const createExecShell = (hosts = [], command = 'ls', timeout = 60) => {
+const createExecShell = (hostIds = [], command = 'ls', timeout = 60) => {
loading.value = true
timeRemaining.value = Number(formData.timeout)
let timer = null
@@ -243,7 +244,7 @@ const createExecShell = (hosts = [], command = 'ls', timeout = 60) => {
pendingRecord.value = [] // 每轮执行前清空
})
- socket.value.emit('create', { hosts, token: token.value, command, timeout })
+ socket.value.emit('create', { hostIds, token: token.value, command, timeout })
socket.value.on('output', (result) => {
loading.value = false
@@ -320,9 +321,9 @@ onMounted(async () => {
let selectAllHost = (val) => {
indeterminate.value = false
if (val) {
- formData.hosts = hasConfigHostList.value.map(item => item.host)
+ formData.hostIds = hasConfigHostList.value.map(item => item.id)
} else {
- formData.hosts = []
+ formData.hostIds = []
}
}
@@ -366,16 +367,16 @@ let addOnekey = () => {
function execOnekey() {
updateFormRef.value.validate()
.then(async () => {
- let { hosts, command, timeout } = formData
+ let { hostIds, command, timeout } = formData
timeout = Number(timeout)
if (timeout < 1) {
return $message.error('超时时间不能小于1秒')
}
- if (hosts.length === 0) {
+ if (hostIds.length === 0) {
return $message.error('请选择主机')
}
await getOnekeyRecord() // 获取新纪录前会清空 pendingRecord,所以需要获取一次最新的list
- createExecShell(hosts, command, timeout)
+ createExecShell(hostIds, command, timeout)
formVisible.value = false
})
}
@@ -407,11 +408,12 @@ const handleRemoveAll = async () => {
onActivated(async () => {
await nextTick()
- const { host, execClientInstallScript } = route.query
- if (!host) return
+ const { hostIds, execClientInstallScript } = route.query
+ if (!hostIds) return
if (execClientInstallScript === 'true') {
let clientInstallScript = 'curl -o- https://mirror.ghproxy.com/https://raw.githubusercontent.com/chaos-zhu/easynode/main/client/easynode-client-install.sh | bash\n'
- createExecShell(host.split(','), clientInstallScript, 300)
+ console.log(hostIds.split(','))
+ createExecShell(hostIds.split(','), clientInstallScript, 300)
// $messageBox.confirm(`准备安装客户端服务监控应用:${ host }`, 'Warning', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
diff --git a/web/src/views/server/components/host-card.vue b/web/src/views/server/components/host-card.vue
deleted file mode 100644
index b4ee8db..0000000
--- a/web/src/views/server/components/host-card.vue
+++ /dev/null
@@ -1,392 +0,0 @@
-
-
-
- 未连接
- 已连接
-
-
-
-
-
-
-
-
-
-
系统
- 名称: {{ osInfo.hostname }}
- 类型: {{ osInfo.type }}
- 架构: {{ osInfo.arch }}
- 平台: {{ osInfo.platform }}
- 版本: {{ osInfo.release }}
- 开机时长: {{ $tools.formatTime(osInfo.uptime) }}
- 到期时间: {{ expiredTime }}
- 本地IP: {{ osInfo.ip }}
- 连接数: {{ openedCount || 0 }}
-
-
-
-
- {{ name || '--' }}
-
-
- {{ osInfo?.type || '--' }}
-
-
-
-
-
-
-
-
-
-
位置信息
- 详细: {{ ipInfo.country || '--' }} {{ ipInfo.regionName }}
-
-
- 提供商: {{ ipInfo.isp || '--' }}
- 线路: {{ ipInfo.as || '--' }}
-
-
-
- {{ `${ipInfo?.country || '--'} ${ipInfo?.regionName || '--'}` }}
-
- {{ hostIp }}
-
-
-
-
-
-
-
-
-
CPU
- 利用率: {{ cpuInfo.cpuUsage }}%
- 物理核心: {{ cpuInfo.cpuCount }}
- 型号: {{ cpuInfo.cpuModel }}
-
-
-
- {{ cpuInfo.cpuUsage || '0' || '--' }}%
- {{ cpuInfo.cpuCount || '--' }} 核心
-
-
-
-
-
-
-
-
-
内存
- 总大小: {{ $tools.toFixed(memInfo.totalMemMb / 1024) }} GB
- 已使用: {{ $tools.toFixed(memInfo.usedMemMb / 1024) }} GB
- 占比: {{ $tools.toFixed(memInfo.usedMemPercentage) }}%
- 空闲: {{ $tools.toFixed(memInfo.freeMemMb / 1024) }} GB
-
-
-
- {{ $tools.toFixed(memInfo.usedMemPercentage)
- }}%
- {{ $tools.toFixed(memInfo.usedMemMb / 1024) }} | {{ $tools.toFixed(memInfo.totalMemMb / 1024) }} GB
-
-
-
-
-
-
-
-
-
存储
- 总空间: {{ driveInfo.totalGb || '--' }} GB
- 已使用: {{ driveInfo.usedGb || '--' }} GB
- 剩余: {{ driveInfo.freeGb || '--' }} GB
- 占比: {{ driveInfo.usedPercentage || '--' }}%
-
-
-
- {{ driveInfo.usedPercentage || '--' }}%
- {{ driveInfo.usedGb || '--' }} | {{ driveInfo.totalGb || '--' }} GB
-
-
-
-
-
-
-
-
-
网卡
-
-
-
- {{ key }}
-
↑ {{ $tools.formatNetSpeed(value?.outputMb) || 0 }}
- ↓ {{ $tools.formatNetSpeed(value?.inputMb) || 0 }}
-
-
-
-
-
- ↑ {{ $tools.formatNetSpeed(netstatInfo.netTotal?.outputMb) || 0 }}
- ↓ {{ $tools.formatNetSpeed(netstatInfo.netTotal?.inputMb) || 0 }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/web/src/views/server/components/host-table.vue b/web/src/views/server/components/host-table.vue
index 1ee691b..c94dea1 100644
--- a/web/src/views/server/components/host-table.vue
+++ b/web/src/views/server/components/host-table.vue
@@ -3,7 +3,7 @@
{
}
const handleSSH = async (row) => {
- let { host } = row
- $router.push({ path: '/terminal', query: { host } })
+ let { id } = row
+ $router.push({ path: '/terminal', query: { hostIds: id } })
}
const handleOnekey = async (row) => {
- let { host, isConfig } = row
+ let { id, isConfig } = row
if (!isConfig) {
$message({
message: '请先配置SSH连接信息',
@@ -143,7 +143,7 @@ const handleOnekey = async (row) => {
handleUpdate(row)
return
}
- $router.push({ path: '/onekey', query: { host, execClientInstallScript: 'true' } })
+ $router.push({ path: '/onekey', query: { hostIds: id, execClientInstallScript: 'true' } })
}
let defaultSortLocal = localStorage.getItem('host_table_sort')
@@ -175,13 +175,13 @@ defineExpose({
clearSelection
})
-const handleRemoveHost = async ({ host }) => {
+const handleRemoveHost = async ({ id }) => {
$messageBox.confirm('确认删除实例', 'Warning', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
- let { data } = await $api.removeHost({ host })
+ let { data } = await $api.removeHost({ ids: [id,] })
$message({
message: data,
type: 'success',
diff --git a/web/src/views/server/index.vue b/web/src/views/server/index.vue
index 5873690..0b7970d 100644
--- a/web/src/views/server/index.vue
+++ b/web/src/views/server/index.vue
@@ -121,10 +121,10 @@ let collectSelectHost = () => {
let handleBatchSSH = () => {
collectSelectHost()
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
- let ips = selectHosts.value.filter(item => item.isConfig).map(item => item.host)
- if (!ips.length) return $message.warning('所选实例未配置ssh连接信息')
- if (ips.length < selectHosts.value.length) $message.warning('部分实例未配置ssh连接信息,已忽略')
- $router.push({ path: '/terminal', query: { host: ips.join(',') } })
+ let ids = selectHosts.value.filter(item => item.isConfig).map(item => item.id)
+ if (!ids.length) return $message.warning('所选实例未配置ssh连接信息')
+ if (ids.length < selectHosts.value.length) $message.warning('部分实例未配置ssh连接信息,已忽略')
+ $router.push({ path: '/terminal', query: { hostIds: ids.join(',') } })
}
let handleBatchModify = async () => {
@@ -137,7 +137,7 @@ let handleBatchModify = async () => {
let handleBatchRemove = async () => {
collectSelectHost()
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
- let ips = selectHosts.value.map(item => item.host)
+ let ids = selectHosts.value.map(item => item.id)
let names = selectHosts.value.map(item => item.name)
$messageBox.confirm(() => h('p', { style: 'line-height: 18px;' }, `确认删除\n${ names.join(', ') }吗?`), 'Warning', {
@@ -145,7 +145,7 @@ let handleBatchRemove = async () => {
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
- let { data } = await $api.removeHost({ host: ips })
+ let { data } = await $api.removeHost({ ids })
$message({ message: data, type: 'success', center: true })
selectHosts.value = []
await handleUpdateList()
@@ -161,8 +161,8 @@ let handleUpdateHost = (defaultData) => {
let handleBatchOnekey = async () => {
collectSelectHost()
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
- let ips = selectHosts.value.map(item => item.host).join(',')
- $router.push({ path: '/onekey', query: { host: ips, execClientInstallScript: 'true' } })
+ let ids = selectHosts.value.map(item => item.id).join(',')
+ $router.push({ path: '/onekey', query: { hostIds: ids, execClientInstallScript: 'true' } })
}
let handleBatchExport = () => {
diff --git a/web/src/views/terminal/index.vue b/web/src/views/terminal/index.vue
index a786a3b..cb2c517 100644
--- a/web/src/views/terminal/index.vue
+++ b/web/src/views/terminal/index.vue
@@ -101,9 +101,9 @@ const handleUpdateList = async ({ host }) => {
onActivated(async () => {
await nextTick()
- const { host } = route.query
- if (!host) return
- let targetHosts = hostList.value.filter(item => host.includes(item.host)).map(item => {
+ const { hostIds } = route.query
+ if (!hostIds) return
+ let targetHosts = hostList.value.filter(item => hostIds.includes(item.id)).map(item => {
const { name, host } = item
return { key: randomStr(16), name, host, status: CONNECTING }
})