From 7cc37b05233cc17909dc73c6235fe25c5d80cb8d Mon Sep 17 00:00:00 2001 From: kubbo <390378816@qq.com> Date: Thu, 24 Apr 2025 20:07:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E4=BF=AE=E5=A4=8D=E7=89=A9?= =?UTF-8?q?=E5=93=81=E5=8F=91=E9=80=81=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将物品发送请求的参数格式从 { role, item: [itemId, itemNum] } 修改为 { role, item: [[itemId, itemNum]] } - 添加对返回结果的处理,根据 result.data.result 判断发送是否成功 - 成功时返回原来的成功消息,失败时返回失败消息和具体错误内容 --- server/src/routes/role.routes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/routes/role.routes.js b/server/src/routes/role.routes.js index 4ad23f5..f5bb120 100644 --- a/server/src/routes/role.routes.js +++ b/server/src/routes/role.routes.js @@ -30,7 +30,7 @@ router.post("/item/send", async (req, res) => { const role = roleId[0].id; const result = await axios.post( "http://192.168.25.110:19000/center/gm", - { role, item: [itemId, itemNum] }, + { role, item: [[itemId, itemNum]] }, { headers: { Accept: "application/json, text/plain, */*", @@ -44,7 +44,8 @@ router.post("/item/send", async (req, res) => { } ); console.log("物品[%s]发送给[%s]结果:%s", itemId, roleName, result.data); - res.json({ code: 0, msg: "发送成功!" }); + if (result.data.result) res.json({ code: 0, msg: "发送成功!" }); + else res.json({ code: 1, msg: result.data.content }); } catch (error) { console.error("获取角色数据失败:", error); res.status(500).json({ error: "获取角色数据失败" });