fix(proxies): disconnect after proxy is changed

This commit is contained in:
Zephyruso 2023-09-08 15:09:19 +08:00
parent e4021bbe47
commit a8cb75f29d

View File

@ -82,6 +82,12 @@ export const useProxies = () => {
const proxyGroupList = proxies().slice() const proxyGroupList = proxies().slice()
const proxyGroup = proxyGroupList.find((i) => i.name === proxy.name)! const proxyGroup = proxyGroupList.find((i) => i.name === proxy.name)!
await request.put(`proxies/${proxy.name}`, {
body: JSON.stringify({
name: proxyName,
}),
})
if (autoCloseConns()) { if (autoCloseConns()) {
activeConnections().forEach(({ id, chains }) => { activeConnections().forEach(({ id, chains }) => {
if (chains.includes(proxy.name)) { if (chains.includes(proxy.name)) {
@ -90,14 +96,7 @@ export const useProxies = () => {
}) })
} }
await request.put(`proxies/${proxy.name}`, {
body: JSON.stringify({
name: proxyName,
}),
})
proxyGroup.now = proxyName proxyGroup.now = proxyName
setProxies(proxyGroupList) setProxies(proxyGroupList)
} }