feat: 实现客户端实例上报功能

- 新增 ClientInstance 模型,记录客户端 IP 与配置项的关联
- 配置拉取接口(fetchAll/fetchChanged)自动记录客户端信息
- 配置列表页面展示每个配置的在线客户端数量
- 点击可查看具体 IP 地址、拉取方式、最后拉取时间
- 超过 5 分钟未拉取的记录自动清理
- 注释掉 /api/ping 接口
This commit is contained in:
2026-04-27 21:07:37 +08:00
parent b4b38fa0c7
commit ed94f53306
9 changed files with 167 additions and 5 deletions
+36 -1
View File
@@ -25,6 +25,14 @@
</template>
</el-table-column>
<el-table-column prop="version" label="版本" width="100"></el-table-column>
<el-table-column prop="clientCount" label="在线客户端" width="120">
<template slot-scope="scope">
<el-button v-if="scope.row.clientCount > 0" type="text" @click="showClients(scope.row)">
{{ scope.row.clientCount }} 个
</el-button>
<span v-else style="color: #909399">无</span>
</template>
</el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<el-button type="text" @click="showHistory(scope.row)">变更历史</el-button>
@@ -92,11 +100,29 @@
</div>
</div>
</el-dialog>
<el-dialog title="在线客户端" :visible.sync="clientVisible" width="700px">
<el-table :data="clientList" border stripe>
<el-table-column prop="ip" label="IP 地址" width="160"></el-table-column>
<el-table-column prop="lastFetchType" label="拉取方式" width="120">
<template slot-scope="scope">
<span v-if="scope.row.lastFetchType === 'fetchAll'">全量拉取</span>
<span v-else>增量拉取</span>
</template>
</el-table-column>
<el-table-column label="最后拉取时间">
<template slot-scope="scope">
{{ formatTime(scope.row.lastFetchAt) }}
</template>
</el-table-column>
</el-table>
</el-dialog>
</el-card>
</template>
<script>
import { getConfigList, deleteConfig, getConfigHistory, rollbackConfig, getConfig } from '../../api/config'
import { getClientListByConfig } from '../../api/client'
import request from '../../api/request'
function computeDiff(oldText, newText) {
@@ -204,7 +230,9 @@ export default {
contentVisible: false,
currentHistory: {},
leftLines: [],
rightLines: []
rightLines: [],
clientVisible: false,
clientList: []
}
},
created() {
@@ -305,6 +333,13 @@ export default {
this.historyVisible = false
this.loadData()
} catch (e) {}
},
async showClients(row) {
try {
const res = await getClientListByConfig(row.id)
this.clientList = res.data || []
this.clientVisible = true
} catch (e) {}
}
}
}