fix: 状态问题

This commit is contained in:
song_xiao_lin
2024-05-15 14:43:04 +08:00
committed by go0p
parent ddf036da66
commit 52a8d315d1
+6 -1
View File
@@ -56,7 +56,12 @@ export const Contro: React.FC<ControProps> = () => {
const findPort = (port: number, max: number) => { const findPort = (port: number, max: number) => {
const ws = new WebSocket(`ws://127.0.0.1:${port}`); const ws = new WebSocket(`ws://127.0.0.1:${port}`);
ws.onclose = (e: CloseEvent) => { ws.onclose = (e: CloseEvent) => {
if (enginePortRef.current) return if (enginePortRef.current) {
setConnected(false);
setAutoFindFailedReason("Yakit WebSocket Controller Connect Fail");
localStorage.setItem("yakit-connect", "");
return
}
if (e.reason !== `FoundYakitWebSocketController` && port + 1 <= max) { if (e.reason !== `FoundYakitWebSocketController` && port + 1 <= max) {
setTimeout(() => findPort(port + 1, max), 200); setTimeout(() => findPort(port + 1, max), 200);
} }