mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-27 05:31:53 +08:00
proxy operation implemented
This commit is contained in:
@@ -30,6 +30,10 @@ export const Proxifier: React.FC<ProxifierProp> = (props) => {
|
||||
}
|
||||
|
||||
wsc.onProxyStatusMessage(msg => {
|
||||
if (msg['proxy'] === undefined || msg['enable'] === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
setInit(true)
|
||||
setProxyEnable(msg.enable)
|
||||
setCurrentProxy(msg.proxy)
|
||||
@@ -42,19 +46,23 @@ export const Proxifier: React.FC<ProxifierProp> = (props) => {
|
||||
wsc.updateProxyStatus()
|
||||
}
|
||||
update()
|
||||
const id = setInterval(update, 1000)
|
||||
const id = setInterval(update, 500)
|
||||
return () => {
|
||||
clearInterval(id)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <Card title={`代理设置: ${proxyEnable ? currentProxy : "未启用"}`}>
|
||||
return <Card title={`Proxy Set: ${proxyEnable ? currentProxy : "Non-Config"}`} size={"small"} extra={<>{
|
||||
proxyEnable ? <Button size={"small"} onClick={() => {
|
||||
wsc.clearproxy()
|
||||
}}>停用</Button> : undefined
|
||||
}</>}>
|
||||
<Form size={"small"} onSubmitCapture={e => {
|
||||
e.preventDefault()
|
||||
setInit(false)
|
||||
wsc.setproxy(config.scheme, config.host, config.port)
|
||||
}} disabled={!init}>
|
||||
<Form.Item label={"设置代理"}>
|
||||
}} disabled={!init || proxyEnable}>
|
||||
<Form.Item label={"Proxy Setting"}>
|
||||
<Compact>
|
||||
<Select
|
||||
style={{width: 86}}
|
||||
@@ -78,7 +86,7 @@ export const Proxifier: React.FC<ProxifierProp> = (props) => {
|
||||
</Compact>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button htmlType={"submit"} loading={!init}>启用链接</Button>
|
||||
<Button type={"primary"} htmlType={"submit"} loading={!init}>Enable Proxy</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user