From 26c3bbc5708c07205a456d6a8194c3fcb249ccbf Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Tue, 14 May 2024 16:42:11 +0800 Subject: [PATCH] =?UTF-8?q?del:=20=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 - src/components/Controller.tsx | 95 ----------------------------------- 2 files changed, 97 deletions(-) delete mode 100644 src/components/Controller.tsx diff --git a/src/App.tsx b/src/App.tsx index 795418f..e47f96f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,7 +3,6 @@ import "./App.css"; import {ConfigProvider} from "antd"; import {Contro} from "@components/Contro"; import {Proxifier} from "@components/Proxifier"; -import {Controller} from "./components/Controller"; import {Eval} from "@components/Eval"; import {EvalInTab} from "@components/EvalInTab"; @@ -22,7 +21,6 @@ function App() { - {/* */} ); diff --git a/src/components/Controller.tsx b/src/components/Controller.tsx deleted file mode 100644 index bdb6415..0000000 --- a/src/components/Controller.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, {useEffect} from "react"; -import {Alert, Button, Card, Form, InputNumber} from "antd"; -import {wsc} from "../network/chrome"; -import {useGetState} from "ahooks"; - -export interface ControllerProp { - -} - -export const Controller: React.FC = (props) => { - const [findingPort, setFindingPort] = React.useState(false) - const [autoFindFailedReason, setAutoFindFailedReason] = React.useState("") - const [port, setPort] = React.useState() - - const [connected, setConnected, getConnected] = useGetState(false); - const [init, setInit] = React.useState(false) - - useEffect(() => { - // control status - const updateStatus = () => { - wsc.updateWSCStatus() - } - updateStatus() - const id = setInterval(updateStatus, 500) - - wsc.onWSCMessage((req: { connected: boolean }) => { - if (req['connected'] === undefined) { - return - } - - setConnected(req.connected) - setTimeout(() => { - setInit(true) - }, 500) - }) - return () => { - clearInterval(id) - } - }, []) - - useEffect(() => { - if (!init || connected) { - return - } - - const findPort = (port: number, max: number) => { - const ws = new WebSocket(`ws://127.0.0.1:${port}`) - ws.onclose = (e: CloseEvent) => { - if (e.reason !== `FoundYakitWebSocketController` && (port + 1 <= max)) { - setTimeout(() => findPort(port + 1, max), 300) - } - - if (port + 1 > max) { - setFindingPort(false) - setAutoFindFailedReason("Cannot found Yakit or Yakit WebSocket Controller Port is not right") - } - } - ws.onopen = () => { - setFindingPort(false) - setPort(port) - ws.close(1000, "FoundYakitWebSocketController") - } - } - findPort(11212, 11222) - }, [connected, init]) - - const freeze = findingPort || (!init); - const safeConnected = connected && init; - - return { - wsc.disconnect() - }}> - Disconnect - : undefined}> - {connected && init ? - : -
{ - e.preventDefault() - - wsc.connect(port) - }} - size={"small"} - > - {autoFindFailedReason !== '' ? : undefined} - - setPort(e)}/> - - - - - } -
-}; \ No newline at end of file