feat(api): 添加客户端状态接口
- 新增 client/status.js 文件实现客户端状态获取功能 - 移除 add.js 中未使用的 console.log 引用
This commit is contained in:
@@ -2,7 +2,6 @@ const { randomUUID } = require("crypto");
|
|||||||
const ins = require("../../utils/http");
|
const ins = require("../../utils/http");
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
const getCookie = require("../../auth/3xuiLogin");
|
const getCookie = require("../../auth/3xuiLogin");
|
||||||
const { log } = require("console");
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
let { id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email } = ctx.request.body;
|
let { id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email } = ctx.request.body;
|
||||||
|
|||||||
19
api/client/status.js
Normal file
19
api/client/status.js
Normal file
@@ -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",
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user