mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 22:11:56 +08:00
Fix: use jsBridge to delay test
This commit is contained in:
parent
ba2ec0d77f
commit
21fae29d84
@ -3,6 +3,7 @@ import classnames from 'classnames'
|
|||||||
// import { Icon } from '@components'
|
// import { Icon } from '@components'
|
||||||
import { BaseComponentProps, TagColors } from '@models'
|
import { BaseComponentProps, TagColors } from '@models'
|
||||||
import { getProxyDelay, Proxy as IProxy } from '@lib/request'
|
import { getProxyDelay, Proxy as IProxy } from '@lib/request'
|
||||||
|
import { isClashX, jsBridge } from '@lib/jsBridge'
|
||||||
import { to, getLocalStorageItem, setLocalStorageItem, sample } from '@lib/helper'
|
import { to, getLocalStorageItem, setLocalStorageItem, sample } from '@lib/helper'
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
|
|
||||||
@ -49,6 +50,14 @@ export class Proxy extends React.Component<ProxyProps , ProxyState> {
|
|||||||
|
|
||||||
async componentDidMount () {
|
async componentDidMount () {
|
||||||
const { config } = this.props
|
const { config } = this.props
|
||||||
|
if (isClashX()) {
|
||||||
|
const delay = await jsBridge.getProxyDelay(config.name)
|
||||||
|
if (delay === 0) {
|
||||||
|
return this.setState({ hasError: true })
|
||||||
|
}
|
||||||
|
return this.setState({ delay })
|
||||||
|
}
|
||||||
|
|
||||||
const [res, err] = await to(getProxyDelay(config.name))
|
const [res, err] = await to(getProxyDelay(config.name))
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -150,15 +150,19 @@ export class JsBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getStartAtLogin () {
|
public getStartAtLogin () {
|
||||||
return this.callHandler<Boolean>('getStartAtLogin')
|
return this.callHandler<boolean>('getStartAtLogin')
|
||||||
|
}
|
||||||
|
|
||||||
|
public getProxyDelay (name: string) {
|
||||||
|
return this.callHandler<number>('speedTest', name)
|
||||||
}
|
}
|
||||||
|
|
||||||
public setStartAtLogin (data: boolean) {
|
public setStartAtLogin (data: boolean) {
|
||||||
return this.callHandler<Boolean>('setStartAtLogin', data)
|
return this.callHandler<boolean>('setStartAtLogin', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSystemProxySet () {
|
public isSystemProxySet () {
|
||||||
return this.callHandler<Boolean>('isSystemProxySet')
|
return this.callHandler<boolean>('isSystemProxySet')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user