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() await rootStores.store.fetchAndParseConfig()
const startAtLogin = await jsBridge.getStartAtLogin() const startAtLogin = await jsBridge.getStartAtLogin()
const setAsSystemProxy = await jsBridge.isSystemProxySet() const setAsSystemProxy = await jsBridge.isSystemProxySet()
const apiInfo = await jsBridge.getAPIInfo()
this.setState({ this.setState({
startAtLogin, startAtLogin,
setAsSystemProxy, setAsSystemProxy,
isClashX: true isClashX: true,
externalControllerHost: apiInfo.host,
externalControllerPort: apiInfo.port,
externalControllerSecret: apiInfo.secret
}) })
} }
await rootStores.store.fetchData() await rootStores.store.fetchData()
const config = rootStores.store.config.general
const general = rootStores.store.data.general const general = rootStores.store.data.general
this.setState({ this.setState({
allowConnectFromLan: general.allowLan, allowConnectFromLan: general.allowLan,
proxyMode: general.mode, proxyMode: general.mode,
socks5ProxyPort: general.socksPort, socks5ProxyPort: general.socksPort,
httpProxyPort: general.port, httpProxyPort: general.port
externalControllerHost: config.externalControllerAddr,
externalControllerPort: config.externalControllerPort,
externalControllerSecret: config.secret
}) })
} }

View File

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