From 9389ee817e1dff348861b171e3e54154e8436cfa Mon Sep 17 00:00:00 2001 From: MoonLeeeaf <150461955+MoonLeeeaf@users.noreply.github.com> Date: Sat, 22 Mar 2025 22:32:52 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=87=8D=E5=86=99=E4=B8=BB=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=96=B9=E6=B3=95=E6=9F=A5=E6=89=BE=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/main.js b/server/main.js index bcc4425..554a4b3 100644 --- a/server/main.js +++ b/server/main.js @@ -25,11 +25,17 @@ io.on("connection", (socket) => { socket.on('the_white_silk', /** * @param { TheWhiteSilkParams } params - * @param { Function<> } callback + * @param { Function } callback */ (params, callback) => { - if ((params || callback) == null || typeof callback != Function) return; - (events[params.method] || (() => callback({mess})))(params.args) + if ((params || callback) == null || typeof callback != 'function') return; + + /** @type { CallbackMessage } */ + let data = events[params.method] ? events[params.method](params.args) : { + msg: '找不到此方法', + code: CallbackMessage.Code.NOT_FOUND, + } + callback(data) } ) })