[refactor] string values to json

This commit is contained in:
Alireza Ahmadi
2024-06-06 22:07:26 +02:00
parent c994f4b24a
commit 2cabf0aefb
12 changed files with 121 additions and 138 deletions
+4 -4
View File
@@ -141,7 +141,7 @@ const updateLinks = (i:any,tlsClient:any) => {
i.users.forEach((u:any) => {
const client = clients.value.find(c => u.username? c.name == u.username : c.name == u.name)
if (client){
const clientInbounds = <Inbound[]>inbounds.value.filter(inb => client?.inbounds.split(',').includes(inb.tag))
const clientInbounds = <Inbound[]>inbounds.value.filter(inb => client?.inbounds.includes(inb.tag))
const newLinks = <Link[]>[]
clientInbounds.forEach(i =>{
const uri = LinkUtil.linkGenerator(client.name,i,tlsClient)
@@ -149,10 +149,10 @@ const updateLinks = (i:any,tlsClient:any) => {
newLinks.push(<Link>{ type: 'local', remark: i.tag, uri: uri })
}
})
let links = client.links && client.links.length>0? <Link[]>JSON.parse(client.links) : <Link[]>[]
links = [...newLinks, ...links.filter(l => l.type != 'local')]
let links = client.links && client.links.length>0? client.links : <Link[]>[]
links = [...newLinks, ...links.filter((l:Link) => l.type != 'local')]
client.links = JSON.stringify(links)
client.links = links
}
})
}