update pay ui
This commit is contained in:
20
app.py
20
app.py
@@ -318,8 +318,8 @@ if USE_REDIS_SESSION:
|
|||||||
app.config['SESSION_PERMANENT'] = True
|
app.config['SESSION_PERMANENT'] = True
|
||||||
app.config['SESSION_USE_SIGNER'] = True # 对 session cookie 签名,提高安全性
|
app.config['SESSION_USE_SIGNER'] = True # 对 session cookie 签名,提高安全性
|
||||||
app.config['SESSION_KEY_PREFIX'] = 'vf_session:' # session key 前缀
|
app.config['SESSION_KEY_PREFIX'] = 'vf_session:' # session key 前缀
|
||||||
# 显式设置 Session 生命周期为 7 天(Flask-Session 会用这个值设置 Redis TTL)
|
app.config['SESSION_REFRESH_EACH_REQUEST'] = True # 每次请求都刷新 session TTL
|
||||||
app.config['SESSION_LIFETIME'] = timedelta(days=7)
|
# 注意:Flask-Session 使用 PERMANENT_SESSION_LIFETIME 作为 Redis TTL(下面已配置为7天)
|
||||||
print(f"📦 Flask Session 配置: Redis {_REDIS_HOST}:{_REDIS_PORT}/db=1, 过期时间: 7天")
|
print(f"📦 Flask Session 配置: Redis {_REDIS_HOST}:{_REDIS_PORT}/db=1, 过期时间: 7天")
|
||||||
else:
|
else:
|
||||||
# 使用默认的 cookie session(单 Worker 模式可用)
|
# 使用默认的 cookie session(单 Worker 模式可用)
|
||||||
@@ -343,6 +343,21 @@ if USE_REDIS_SESSION:
|
|||||||
Session(app)
|
Session(app)
|
||||||
print("✅ Flask-Session (Redis) 已初始化,支持多 Worker 共享 session")
|
print("✅ Flask-Session (Redis) 已初始化,支持多 Worker 共享 session")
|
||||||
|
|
||||||
|
# 确保 session 使用永久模式(解决 Flask-Session 0.8.0 默认 1 小时 TTL 问题)
|
||||||
|
@app.before_request
|
||||||
|
def make_session_permanent():
|
||||||
|
"""每次请求开始时确保 session 是永久的,使用 PERMANENT_SESSION_LIFETIME 作为 TTL"""
|
||||||
|
from flask import session
|
||||||
|
session.permanent = True
|
||||||
|
|
||||||
|
# 确保每次请求后刷新 session TTL(解决 session 过早过期问题)
|
||||||
|
@app.after_request
|
||||||
|
def refresh_session(response):
|
||||||
|
"""每次请求后标记 session 为已修改,触发 Redis TTL 刷新"""
|
||||||
|
from flask import session
|
||||||
|
session.modified = True
|
||||||
|
return response
|
||||||
|
|
||||||
# 配置邮件
|
# 配置邮件
|
||||||
app.config['MAIL_SERVER'] = MAIL_SERVER
|
app.config['MAIL_SERVER'] = MAIL_SERVER
|
||||||
app.config['MAIL_PORT'] = MAIL_PORT
|
app.config['MAIL_PORT'] = MAIL_PORT
|
||||||
@@ -459,6 +474,7 @@ socketio = SocketIO(
|
|||||||
"https://valuefrontier.cn", "http://valuefrontier.cn"],
|
"https://valuefrontier.cn", "http://valuefrontier.cn"],
|
||||||
async_mode=_async_mode,
|
async_mode=_async_mode,
|
||||||
message_queue=SOCKETIO_MESSAGE_QUEUE if _use_message_queue else None,
|
message_queue=SOCKETIO_MESSAGE_QUEUE if _use_message_queue else None,
|
||||||
|
manage_session=False, # 让 Flask-Session 管理 session,避免与 SocketIO 冲突
|
||||||
logger=True,
|
logger=True,
|
||||||
engineio_logger=False,
|
engineio_logger=False,
|
||||||
ping_timeout=120, # 心跳超时时间(秒),客户端120秒内无响应才断开
|
ping_timeout=120, # 心跳超时时间(秒),客户端120秒内无响应才断开
|
||||||
|
|||||||
Reference in New Issue
Block a user