Horis 3 лет назад
Родитель
Сommit
9b3f36996b

+ 4 - 0
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
                 }
             }
         }

+ 1 - 1
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);