Initial commit
This commit is contained in:
73
test_current_config.py
Normal file
73
test_current_config.py
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
测试当前用户配置和订阅状态
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
# 测试用户会话API
|
||||
def test_user_session():
|
||||
"""测试用户会话API返回的数据格式"""
|
||||
try:
|
||||
# 注意:这个测试需要在登录状态下进行
|
||||
# 实际测试时需要在浏览器环境中进行
|
||||
print("🔍 分析用户会话API的数据结构...")
|
||||
|
||||
# 模拟预期的数据结构
|
||||
expected_structure = {
|
||||
'success': True,
|
||||
'isAuthenticated': True,
|
||||
'user': {
|
||||
'id': 1,
|
||||
'username': 'test_user',
|
||||
'nickname': '测试用户',
|
||||
'email': 'test@example.com',
|
||||
'phone': '13800138000',
|
||||
'phone_confirmed': True,
|
||||
'email_confirmed': True,
|
||||
'avatar_url': None,
|
||||
'has_wechat': False,
|
||||
'created_at': '2024-01-01T00:00:00',
|
||||
'last_seen': '2024-01-01T12:00:00',
|
||||
# 订阅相关字段(修复后的)
|
||||
'subscription_type': 'max', # free, pro, max
|
||||
'subscription_status': 'active', # active, inactive
|
||||
'subscription_end_date': '2024-12-31T23:59:59',
|
||||
'is_subscription_active': True,
|
||||
'subscription_days_left': 365
|
||||
}
|
||||
}
|
||||
|
||||
print("✅ 预期的用户数据结构:")
|
||||
print(json.dumps(expected_structure, indent=2, ensure_ascii=False))
|
||||
|
||||
# 检查前端使用的字段
|
||||
print("\n📱 前端订阅页面使用的字段:")
|
||||
frontend_fields = [
|
||||
'currentUser.subscription_type',
|
||||
'currentUser.subscription_status',
|
||||
'currentUser.subscription_end_date'
|
||||
]
|
||||
|
||||
for field in frontend_fields:
|
||||
print(f" - {field}")
|
||||
|
||||
print("\n🔧 修复说明:")
|
||||
print("1. 后端API现在返回前端期望的字段名")
|
||||
print("2. 添加了 subscription_ 前缀以避免命名冲突")
|
||||
print("3. 保留了 is_subscription_active 和 subscription_days_left 作为额外信息")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ 测试失败: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🚀 开始测试用户会话API配置...")
|
||||
success = test_user_session()
|
||||
if success:
|
||||
print("\n✅ 测试完成!修复应该可以解决订阅状态显示问题。")
|
||||
else:
|
||||
print("\n❌ 测试失败,请检查配置。")
|
||||
Reference in New Issue
Block a user