mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +08:00
fix(ProxyManager): store original Axios adapter for proxy management (#8875)
This commit is contained in:
parent
ef208bf9e5
commit
12051811fc
@ -72,6 +72,8 @@ export class ProxyManager {
|
||||
private originalHttpsGet: typeof https.get
|
||||
private originalHttpsRequest: typeof https.request
|
||||
|
||||
private originalAxiosAdapter
|
||||
|
||||
constructor() {
|
||||
this.originalGlobalDispatcher = getGlobalDispatcher()
|
||||
this.originalSocksDispatcher = global[Symbol.for('undici.globalDispatcher.1')]
|
||||
@ -79,6 +81,7 @@ export class ProxyManager {
|
||||
this.originalHttpRequest = http.request
|
||||
this.originalHttpsGet = https.get
|
||||
this.originalHttpsRequest = https.request
|
||||
this.originalAxiosAdapter = axios.defaults.adapter
|
||||
}
|
||||
|
||||
private async monitorSystemProxy(): Promise<void> {
|
||||
@ -246,9 +249,9 @@ export class ProxyManager {
|
||||
if (config.mode === 'direct' || !proxyUrl) {
|
||||
setGlobalDispatcher(this.originalGlobalDispatcher)
|
||||
global[Symbol.for('undici.globalDispatcher.1')] = this.originalSocksDispatcher
|
||||
axios.defaults.adapter = 'http'
|
||||
this.proxyDispatcher?.close()
|
||||
this.proxyDispatcher = null
|
||||
axios.defaults.adapter = this.originalAxiosAdapter
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user