This commit is contained in:
lejianwen
2025-04-24 11:51:53 +08:00
parent 0967e78ab7
commit 0dfab9edfb
3 changed files with 24 additions and 10 deletions
+14 -8
View File
@@ -29,15 +29,21 @@ export function useRepositories (api_type = 'my') {
const res = await apis[api_type].list(listQuery).catch(_ => false)
listRes.loading = false
if (res) {
const uuids = res.data.list.filter(item => item.uuid).map(item => item.uuid)
const peers = await apis[api_type].fetchPeers({ uuids }).catch(_ => false)
if (peers?.data?.list) {
res.data.list.forEach(item => {
if (item.uuid) {
item.peer = peers.data.list.find(peer => peer.uuid === item.uuid)
}
})
//通过uuid补全peer信息
const uuids = res.data.list.filter(item => item.uuid&&item.client==='client'&&!item.device_id).map(item => item.uuid)
if(uuids.length > 0){
//uuids去重
const uniqueUuids = [...new Set(uuids)]
const peers = await apis[api_type].fetchPeers({ uuids: uniqueUuids }).catch(_ => false)
if (peers?.data?.list) {
res.data.list.forEach(item => {
if (item.uuid) {
item.peer = peers.data.list.find(peer => peer.uuid === item.uuid)
}
})
}
}
listRes.list = res.data.list
listRes.total = res.data.total
}