From 068c77da74ce844e76243cdc050836af42b2ecd2 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Sun, 16 Apr 2023 14:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/web/socket/BookSourceDebugWebSocket.kt | 4 ++++ modules/web/src/api/index.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/web/socket/BookSourceDebugWebSocket.kt b/app/src/main/java/io/legado/app/web/socket/BookSourceDebugWebSocket.kt index b98f0a45d..1e158399d 100644 --- a/app/src/main/java/io/legado/app/web/socket/BookSourceDebugWebSocket.kt +++ b/app/src/main/java/io/legado/app/web/socket/BookSourceDebugWebSocket.kt @@ -65,6 +65,10 @@ class BookSourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) : Debug.callback = this@BookSourceDebugWebSocket Debug.startDebug(this, it, key) } + } else { + send("数据必须为Json格式") + close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) + return@launch } } } diff --git a/modules/web/src/api/index.js b/modules/web/src/api/index.js index 207246f21..a743fba2d 100644 --- a/modules/web/src/api/index.js +++ b/modules/web/src/api/index.js @@ -98,7 +98,7 @@ const debug = ( const socket = new WebSocket(url); socket.onopen = () => { - socket.send(`{"tag":"${sourceUrl}", "key":"${searchKey}"}`); + socket.send(JSON.stringify({ tag: sourceUrl, key: searchKey })); }; socket.onmessage = ({ data }) => onReceive(data);