From d5798eacdb28d88094bc2f71fba4eadfdd30fe13 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 26 Feb 2025 16:08:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(api/client):=20=E4=BC=98=E5=8C=96=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在请求体中增加 email 参数,允许自定义用户邮箱 - 如果请求体中未提供 email,则使用随机生成的 UUID 作为邮箱 - 优化了代码结构,提高了可读性和可维护性 --- api/client/add.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/client/add.js b/api/client/add.js index 3cc9ca0..a5d8b8b 100644 --- a/api/client/add.js +++ b/api/client/add.js @@ -5,7 +5,7 @@ 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" } = ctx.request.body; + let { id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email } = ctx.request.body; if (!ctx.state.cookie) { ctx.state.cookie = await getCookie(); ins.interceptors.request.use((config) => { @@ -15,8 +15,8 @@ module.exports = async (ctx) => { } const inbound = await ins.get(`/panel/api/inbounds/get/${id}`); if (!inbound?.success) return (ctx.body = { code: "1", msg: "获取节点失败" }); - const uuid = randomUUID(), - email = uuid.split("-")[0]; + const uuid = randomUUID(); + email = email || uuid.split("-")[0]; if (expiryTime > 0) { expiryTime = dayjs(expiryTime, "YYYY-MM-DD HH:mm:ss").valueOf(); }