fix: 🐛 ip显示问题 (#166)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
nsnail 2024-07-29 18:19:58 +08:00 committed by GitHub
parent 2fa8b56f9c
commit 6b63250039
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -64,9 +64,11 @@
<el-table-column :label="$t('登录名')" prop="loginUserName" sortable="custom" width="150" /> <el-table-column :label="$t('登录名')" prop="loginUserName" sortable="custom" width="150" />
<el-table-column :label="$t('客户端IP')" prop="createdClientIp" show-overflow-tooltip sortable="custom" width="200"> <el-table-column :label="$t('客户端IP')" prop="createdClientIp" show-overflow-tooltip sortable="custom" width="200">
<template #default="{ row }"> <template #default="{ row }">
<template v-if="ips && ips.length > 0 && row.createdClientIp">
<p>{{ row.createdClientIp }}</p> <p>{{ row.createdClientIp }}</p>
<p>{{ this.ips.filter((x) => x.ip === row.createdClientIp)[0]?.region ?? '...' }}</p> <p>{{ this.ips.filter((x) => x.ip === row.createdClientIp)[0]?.region ?? '...' }}</p>
</template> </template>
</template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('操作系统')" align="center" prop="os" width="150" /> <el-table-column :label="$t('操作系统')" align="center" prop="os" width="150" />
<el-table-column :label="$t('用户代理')" prop="createdUserAgent" show-overflow-tooltip sortable="custom" /> <el-table-column :label="$t('用户代理')" prop="createdUserAgent" show-overflow-tooltip sortable="custom" />
@ -117,7 +119,7 @@ export default {
methods: { methods: {
async dataChange(data) { async dataChange(data) {
this.apis = [] this.apis = []
const ips = data.data.rows?.map((x) => x.createdClientIp) const ips = data.data.rows?.map((x) => x.createdClientIp) ?? []
const res = await Promise.all([ const res = await Promise.all([
ips && ips.length > 0 ? http.get(`http://ip.line92.xyz/?ip=${ips.join('&ip=')}`) : new Promise((x) => x({ data: [] })), ips && ips.length > 0 ? http.get(`http://ip.line92.xyz/?ip=${ips.join('&ip=')}`) : new Promise((x) => x({ data: [] })),
]) ])

View File

@ -134,8 +134,10 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('客户端IP')" prop="createdClientIp" show-overflow-tooltip sortable="custom" width="200"> <el-table-column :label="$t('客户端IP')" prop="createdClientIp" show-overflow-tooltip sortable="custom" width="200">
<template #default="{ row }"> <template #default="{ row }">
<template v-if="ips && ips.length > 0 && row.createdClientIp">
<p>{{ row.createdClientIp }}</p> <p>{{ row.createdClientIp }}</p>
<p>{{ this.ips.filter((x) => x.ip === row.createdClientIp)[0]?.region ?? '...' }}</p> <p>{{ ips.filter((x) => x.ip === row.createdClientIp)[0]?.region ?? '...' }}</p>
</template>
</template> </template>
</el-table-column> </el-table-column>
<na-col-operation <na-col-operation
@ -215,7 +217,7 @@ export default {
this.apis = [] this.apis = []
const ownerIds = data.data.rows?.filter((x) => x.ownerId).map((x) => x.ownerId) const ownerIds = data.data.rows?.filter((x) => x.ownerId).map((x) => x.ownerId)
const apiCrcs = data.data.rows?.map((x) => x.apiPathCrc32) const apiCrcs = data.data.rows?.map((x) => x.apiPathCrc32)
const ips = data.data.rows?.map((x) => x.createdClientIp) const ips = data.data.rows?.map((x) => x.createdClientIp) ?? []
const res = await Promise.all([ const res = await Promise.all([
ownerIds && ownerIds.length > 0 ownerIds && ownerIds.length > 0
? this.$API.sys_user.query.post({ ? this.$API.sys_user.query.post({