From 87a408d904db62d668aa8d1778fa6fdff9772d89 Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Sun, 9 Nov 2025 14:32:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0/=5Finfo=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=93=8D=E5=BA=94=EF=BC=8C=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=BF=A1=E6=81=AF=E8=BF=94=E5=9B=9E=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/kv-token.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/routes/kv-token.js b/routes/kv-token.js index cd9f2e4..2cb0ea7 100644 --- a/routes/kv-token.js +++ b/routes/kv-token.js @@ -28,7 +28,7 @@ router.use(prepareTokenForRateLimit); router.get( "/_info", tokenReadLimiter, - errors.catchAsync(async (req, res) => { + errors.catchAsync(async (req, res, next) => { const deviceId = res.locals.deviceId; // 获取设备信息,包含关联的账号 @@ -43,17 +43,24 @@ router.get( return next(errors.createError(404, "设备不存在")); } - // 构建响应对象 + // 构建响应对象:当设备没有关联账号时返回 uuid;若已关联账号则不返回 uuid const response = { device: { id: device.id, - uuid: device.uuid, name: device.name, createdAt: device.createdAt, updatedAt: device.updatedAt, }, }; + // 仅当设备未绑定账号时,包含 uuid 字段 + if (!device.account) { + response.device.uuid = device.uuid; + } + + // 标识是否已绑定账号 + response.hasAccount = !!device.account; + // 如果关联了账号,添加账号信息 if (device.account) { response.account = {