Chore: read API info from jsBridge

This commit is contained in:
Dreamacro 2018-12-21 23:36:35 +08:00
parent dd3ce22bfd
commit 9b0bf2727c
2 changed files with 10 additions and 6 deletions

View File

@ -82,24 +82,24 @@ class Settings extends React.Component<I18nProps, {}> {
await rootStores.store.fetchAndParseConfig()
const startAtLogin = await jsBridge.getStartAtLogin()
const setAsSystemProxy = await jsBridge.isSystemProxySet()
const apiInfo = await jsBridge.getAPIInfo()
this.setState({
startAtLogin,
setAsSystemProxy,
isClashX: true
isClashX: true,
externalControllerHost: apiInfo.host,
externalControllerPort: apiInfo.port,
externalControllerSecret: apiInfo.secret
})
}
await rootStores.store.fetchData()
const config = rootStores.store.config.general
const general = rootStores.store.data.general
this.setState({
allowConnectFromLan: general.allowLan,
proxyMode: general.mode,
socks5ProxyPort: general.socksPort,
httpProxyPort: general.port,
externalControllerHost: config.externalControllerAddr,
externalControllerPort: config.externalControllerPort,
externalControllerSecret: config.secret
httpProxyPort: general.port
})
}

View File

@ -137,6 +137,10 @@ export class JsBridge {
return this.callHandler<string>('getPasteboard')
}
public getAPIInfo () {
return this.callHandler<{ host: string, port: string, secret: string }>('apiInfo')
}
public setPasteboard (data: string) {
return this.callHandler('setPasteboard', data)
}