update ui
This commit is contained in:
17
app.py
17
app.py
@@ -3424,8 +3424,20 @@ def login_with_wechat():
|
||||
# 更新最后登录时间
|
||||
user.update_last_seen()
|
||||
|
||||
# 清除session
|
||||
# ✅ 修复:不立即删除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认证,可以在这里生成
|
||||
|
||||
@@ -144,8 +144,8 @@ export const WECHAT_STATUS = {
|
||||
WAITING: 'waiting',
|
||||
SCANNED: 'scanned',
|
||||
AUTHORIZED: 'authorized',
|
||||
LOGIN_SUCCESS: 'authorized', // ✅ 与后端保持一致,统一使用 'authorized'
|
||||
REGISTER_SUCCESS: 'authorized', // ✅ 与后端保持一致,统一使用 'authorized'
|
||||
LOGIN_SUCCESS: 'login_ready', // ✅ 修复:与后端返回的状态一致
|
||||
REGISTER_SUCCESS: 'register_ready', // ✅ 修复:与后端返回的状态一致
|
||||
EXPIRED: 'expired',
|
||||
AUTH_DENIED: 'auth_denied', // 用户拒绝授权
|
||||
AUTH_FAILED: 'auth_failed', // 授权失败
|
||||
|
||||
Reference in New Issue
Block a user