lejianwen 9 months ago
parent
commit
0dfab9edfb
3 changed files with 24 additions and 10 deletions
  1. 14 8
      src/views/login/log.js
  2. 5 1
      src/views/login/log.vue
  3. 5 1
      src/views/my/login_log/index.vue

+ 14 - 8
src/views/login/log.js

@@ -29,15 +29,21 @@ export function useRepositories (api_type = 'my') {
29
     const res = await apis[api_type].list(listQuery).catch(_ => false)
29
     const res = await apis[api_type].list(listQuery).catch(_ => false)
30
     listRes.loading = false
30
     listRes.loading = false
31
     if (res) {
31
     if (res) {
32
-      const uuids = res.data.list.filter(item => item.uuid).map(item => item.uuid)
33
-      const peers = await apis[api_type].fetchPeers({ uuids }).catch(_ => false)
34
-      if (peers?.data?.list) {
35
-        res.data.list.forEach(item => {
36
-          if (item.uuid) {
37
-            item.peer = peers.data.list.find(peer => peer.uuid === item.uuid)
38
-          }
39
-        })
32
+      //通过uuid补全peer信息
33
+      const uuids = res.data.list.filter(item => item.uuid&&item.client==='client'&&!item.device_id).map(item => item.uuid)
34
+      if(uuids.length > 0){
35
+        //uuids去重
36
+        const uniqueUuids = [...new Set(uuids)]
37
+        const peers = await apis[api_type].fetchPeers({ uuids: uniqueUuids }).catch(_ => false)
38
+        if (peers?.data?.list) {
39
+          res.data.list.forEach(item => {
40
+            if (item.uuid) {
41
+              item.peer = peers.data.list.find(peer => peer.uuid === item.uuid)
42
+            }
43
+          })
44
+        }
40
       }
45
       }
46
+
41
       listRes.list = res.data.list
47
       listRes.list = res.data.list
42
       listRes.total = res.data.total
48
       listRes.total = res.data.total
43
     }
49
     }

+ 5 - 1
src/views/login/log.vue

@@ -28,7 +28,11 @@
28
           </template>
28
           </template>
29
         </el-table-column>
29
         </el-table-column>
30
         <el-table-column prop="client" label="client" align="center" width="120"/>
30
         <el-table-column prop="client" label="client" align="center" width="120"/>
31
-        <el-table-column prop="peer.id" :label="T('Peer')" align="center"/>
31
+        <el-table-column prop="peer.id" :label="T('Peer')" align="center">
32
+          <template #default="{row}">
33
+            {{ row.device_id ? row.device_id : peer?.id }}
34
+          </template>
35
+        </el-table-column>
32
         <el-table-column prop="uuid" label="uuid" align="center"/>
36
         <el-table-column prop="uuid" label="uuid" align="center"/>
33
         <el-table-column prop="ip" label="ip" align="center" width="150"/>
37
         <el-table-column prop="ip" label="ip" align="center" width="150"/>
34
         <el-table-column prop="type" label="type" align="center" width="100"/>
38
         <el-table-column prop="type" label="type" align="center" width="100"/>

+ 5 - 1
src/views/my/login_log/index.vue

@@ -12,7 +12,11 @@
12
       <el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
12
       <el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
13
         <el-table-column type="selection" align="center" width="50"/>
13
         <el-table-column type="selection" align="center" width="50"/>
14
         <el-table-column prop="client" label="client" align="center" width="120"/>
14
         <el-table-column prop="client" label="client" align="center" width="120"/>
15
-        <el-table-column prop="peer.id" :label="T('Peer')" align="center"/>
15
+        <el-table-column prop="peer.id" :label="T('Peer')" align="center">
16
+          <template #default="{row}">
17
+            {{ row.device_id ? row.device_id : peer?.id }}
18
+          </template>
19
+        </el-table-column>
16
         <el-table-column prop="uuid" label="uuid" align="center"/>
20
         <el-table-column prop="uuid" label="uuid" align="center"/>
17
         <el-table-column prop="ip" label="ip" align="center" width="150"/>
21
         <el-table-column prop="ip" label="ip" align="center" width="150"/>
18
         <el-table-column prop="type" label="type" align="center" width="100"/>
22
         <el-table-column prop="type" label="type" align="center" width="100"/>