update ui

This commit is contained in:
2025-11-14 18:48:39 +08:00
parent 43de7f7a52
commit 2753fbc37f
2 changed files with 18 additions and 5 deletions

19
app.py
View File

@@ -3424,8 +3424,20 @@ def login_with_wechat():
# 更新最后登录时间
user.update_last_seen()
# 清除session
del wechat_qr_sessions[session_id]
# ✅ 修复不立即删除session而是标记为已完成避免轮询报错
# 原因:前端可能还在轮询检查状态,立即删除会导致 "无效的session" 错误
# 保留原状态login_ready/register_ready前端会正确处理
# wechat_qr_sessions[session_id]['status'] 保持不变
# 设置延迟删除10秒后自动清理给前端足够时间完成轮询
import threading
def delayed_cleanup():
import time
time.sleep(10)
if session_id in wechat_qr_sessions:
del wechat_qr_sessions[session_id]
print(f"✅ 延迟清理微信登录session: {session_id[:8]}...")
threading.Thread(target=delayed_cleanup, daemon=True).start()
# 生成登录响应
response_data = {
@@ -3442,7 +3454,8 @@ def login_with_wechat():
'wechat_union_id': user.wechat_union_id,
'created_at': user.created_at.isoformat() if user.created_at else None,
'last_seen': user.last_seen.isoformat() if user.last_seen else None
}
},
'isNewUser': session['status'] == 'register_ready' # 标记是否为新用户
}
# 如果需要token认证可以在这里生成