From f759ac1476740c33c61aab59ab4a672d88c8b135 Mon Sep 17 00:00:00 2001
From: geyun <1556375442@qq.com>
Date: Mon, 29 Dec 2025 13:47:13 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=AB=AF=E7=BB=91=E5=AE=9A?=
=?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=20=E5=A2=9E=E5=8A=A0userId?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.html | 11 ++++++-----
server2.js | 10 ----------
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/index.html b/index.html
index 44454c0..35fa0ee 100755
--- a/index.html
+++ b/index.html
@@ -1620,7 +1620,7 @@
console.log(params.get("userId"), 644, params.get("nickname"), params.get("headingimg"));
const encodedUserId = params.get("userId");
- let openId= params.get("openid")?params.get("openid"):'';
+ let openId = params.get("openid") ? params.get("openid") : '';
const from = params.get("from");
let token = params.get("token");//app的token
@@ -1726,7 +1726,8 @@
openId: openId,
phonenumber: document.getElementById('sys-phone').value,
smsCode: document.getElementById('code').value,
- loginPlatForm: 3
+ loginPlatForm: 3,
+ userId: userId
}
retryFetch("https://serviceri.satabot.com/login", {
@@ -1767,7 +1768,7 @@
showToast("登录失败,请重试" + err); // 给用户友好提示
})
.finally(() => {
-
+
if (document.querySelector('.popbox .loading-box')) {
document.querySelector('.popbox .loading-box').classList.add('none');
}
@@ -2727,7 +2728,7 @@
}
}
- async function refreshAiChatNum() {
+ async function refreshAiChatNum() {
const data = {
userId: userId
}
@@ -2737,7 +2738,7 @@
body: JSON.stringify(data) // ✅ 加上 signal
});
}
-
+
function showpop() {
let html = `
diff --git a/server2.js b/server2.js
index 3e60aba..c56154d 100755
--- a/server2.js
+++ b/server2.js
@@ -903,7 +903,6 @@ async function hasQuota(userId) {
async function getQuota(userId) {
const m = getMutex(userId);
return await m.runExclusive(async () => {
- console.log("获取用户对话次数1:", userId, aiChatNum);
console.log("获取用户对话次数:", userId, aiChatNum.get(userId));
return aiChatNum.get(userId);
});
@@ -920,7 +919,6 @@ async function removeQuota(userId) {
// ====================== API ======================
app.post("/refreshAiChatNum", async (req, res) => {
const { userId } = req.body;
- console.log(userId,"刷新对话次数");
try {
const [userRemainChatNum] = await pool.query(
"SELECT ai_chat_num from sys_user where user_id= ?",
@@ -941,18 +939,13 @@ app.post("/analyze", upload.single("file"), async (req, res) => {
try
{
const exists = await hasQuota(userId);
- console.log(exists,"exists");
if (!exists) {
const [userRemainChatNum] = await pool.query(
"SELECT ai_chat_num from sys_user where user_id= ?",
[userId]
);
-
- console.log(userRemainChatNum,"userRemainChatNum");
if (userRemainChatNum.length > 0) {
const quota = userRemainChatNum[0].ai_chat_num;
- console.log(quota,"quota");
- console.log(quota <= 0 && quota !== -1,"quota2");
if (quota <= 0 && quota !== -1) {
return res.status(400).json({ error: "对话次数已用完,请完成账号注册" });
}
@@ -1271,12 +1264,9 @@ app.post("/analyze", upload.single("file"), async (req, res) => {
}
finally {
let userChatNum = await getQuota(userId);
- console.log(userChatNum,"userChatNum2");
if (userChatNum !== -1 && userChatNum !== undefined) {
userChatNum = Math.max(0, userChatNum - 1); // 防止变成负数
- console.log(userChatNum,"userChatNum最终");
await setQuota(userId, userChatNum);
- console.log(`用户剩余AI 对话次数: ${userChatNum}`);
// 更新数据库
await pool.query(
"update sys_user set ai_chat_num = ? where user_id= ?",