proxy operation implemented

This commit is contained in:
v1ll4n
2024-03-21 11:35:18 +08:00
parent bb584fc7d1
commit 18ecead248
2 changed files with 44 additions and 28 deletions
+13 -5
View File
@@ -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>