From 5142e6f245bfdc613ba3d450ad41e88384fe6f75 Mon Sep 17 00:00:00 2001 From: Kubbo <390378816@qq.com> Date: Fri, 28 Feb 2025 22:21:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 client/status.js 文件实现客户端状态获取功能 - 移除 add.js 中未使用的 console.log 引用 --- api/client/add.js | 1 - api/client/status.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 api/client/status.js diff --git a/api/client/add.js b/api/client/add.js index 31974a8..b6935ed 100644 --- a/api/client/add.js +++ b/api/client/add.js @@ -2,7 +2,6 @@ const { randomUUID } = require("crypto"); const ins = require("../../utils/http"); const dayjs = require("dayjs"); const getCookie = require("../../auth/3xuiLogin"); -const { log } = require("console"); module.exports = async (ctx) => { let { id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email } = ctx.request.body; diff --git a/api/client/status.js b/api/client/status.js new file mode 100644 index 0000000..5bffde1 --- /dev/null +++ b/api/client/status.js @@ -0,0 +1,19 @@ +const getCookie = require("../../auth/3xuiLogin"); +const instance = require("../../utils/http"); + +module.exports = async (ctx) => { + let { id } = ctx.request.query; + if (!ctx.state.cookie) { + ctx.state.cookie = await getCookie(); + instance.interceptors.request.use((config) => { + config.headers.Cookie = ctx.state.cookie; + return config; + }); + } + const status = await instance.get(`/panel/api/inbounds/getClientTrafficsById/${id}`); + ctx.body = { + code: 0, + data: status.obj?.[0] || {}, + msg: "success", + }; +};