feat: 更新版本号到8.0.1

This commit is contained in:
Your Name
2025-02-09 23:25:21 +08:00
parent 348c233194
commit ae07d88b28
5 changed files with 165 additions and 82 deletions

View File

@@ -534,15 +534,20 @@ def print_progress(message, delay=0.03):
def get_user_input(prompt, valid_options=None):
"""获取用户输入的美化版本"""
while True:
try:
print(f"\n{Fore.YELLOW}>>>{Fore.WHITE} {prompt}{Style.RESET_ALL}", end=" ")
user_input = input().strip()
if valid_options and user_input not in valid_options:
print(f"{Fore.RED}✗ 无效的输入,请重试{Style.RESET_ALL}")
continue
if valid_options and user_input and user_input not in valid_options:
print(f"{Fore.YELLOW}[提示] 输入无效,请重试{Style.RESET_ALL}")
return get_user_input(prompt, valid_options)
return user_input
except (KeyboardInterrupt, EOFError):
print(f"\n{Fore.YELLOW}[提示] 程序已取消{Style.RESET_ALL}")
sys.exit(0)
except Exception:
return ""
def load_last_account():
@@ -573,53 +578,76 @@ def save_last_account(email):
def verify_member():
"""验证会员身份"""
checker = MemberChecker()
max_retries = 3
retry_count = 0
while True:
print(f"\n{Fore.CYAN}{'='*30} 会员验证 {'='*30}{Style.RESET_ALL}")
# 加载上次使用的账号
last_email, last_used = load_last_account()
if last_email:
print(f"\n{Fore.CYAN}[提示] 上次使用账号: {last_email}")
print(f" 最后使用时间: {last_used}{Style.RESET_ALL}")
print(f"\n{Fore.YELLOW}直接按回车使用上次账号,或输入新的邮箱/订单号{Style.RESET_ALL}")
while retry_count < max_retries:
try:
print(f"\n{Fore.CYAN}{'='*30} 会员验证 {'='*30}{Style.RESET_ALL}")
keyword = get_user_input("请输入会员邮箱或订单号:")
# 如果直接回车且有上次账号记录,使用上次的账号
if not keyword and last_email:
keyword = last_email
print(f"{Fore.CYAN}[信息] 使用上次账号: {keyword}{Style.RESET_ALL}")
elif not keyword:
print(f"{Fore.RED}✗ 输入不能为空,请重试{Style.RESET_ALL}")
continue
# 加载上次使用的账号
last_email, last_used = load_last_account()
if last_email:
print(f"\n{Fore.CYAN}[提示] 上次使用账号: {last_email}")
print(f" 最后使用时间: {last_used}{Style.RESET_ALL}")
print(f"\n{Fore.YELLOW}直接按回车使用上次账号,或输入新的邮箱/订单号{Style.RESET_ALL}")
keyword = get_user_input("请输入会员邮箱或订单号:")
animate_loading("正在验证会员信息", 2) # 使用动画加载替代进度条
result = checker.check_member(keyword)
if result['is_valid']:
# 保存成功验证的账号
save_last_account(keyword)
# 如果直接回车且有上次账号记录,使用上次的账号
if not keyword and last_email:
keyword = last_email
print(f"{Fore.CYAN}[信息] 使用上次账号: {keyword}{Style.RESET_ALL}")
elif not keyword:
if retry_count < max_retries - 1:
print(f"{Fore.YELLOW}[提示] 输入为空,请重试{Style.RESET_ALL}")
retry_count += 1
continue
else:
print(f"{Fore.YELLOW}[提示] 多次输入为空,程序退出{Style.RESET_ALL}")
sys.exit(0)
animate_loading("正在验证会员信息", 2)
result = checker.check_member(keyword)
print(f"\n{Fore.GREEN}✓ 会员验证通过!{Style.RESET_ALL}")
print(f"\n{Fore.CYAN}会员详细信息:{Style.RESET_ALL}")
print(f"{Fore.WHITE}├─ 邮箱: {result['email']}")
print(f"├─ 订单号: {result['order_id']}")
print(f"├─ 到期时间: {result['expire_time']}")
print(f"├─ 使用限制: {result['usage_limit']}")
print(f"└─ 已使用次数: {result['used_count']}{Style.RESET_ALL}")
if result['is_valid']:
# 保存成功验证的账号
save_last_account(keyword)
print(f"\n{Fore.GREEN}✓ 会员验证通过!{Style.RESET_ALL}")
print(f"\n{Fore.CYAN}会员详细信息:{Style.RESET_ALL}")
print(f"{Fore.WHITE}├─ 邮箱: {result['email']}")
print(f"├─ 订单号: {result['order_id']}")
print(f"├─ 到期时间: {result['expire_time']}")
print(f"├─ 使用限制: {result['usage_limit']}")
print(f"└─ 已使用次数: {result['used_count']}{Style.RESET_ALL}")
if result['expire_time']:
expire_time = datetime.strptime(result['expire_time'], "%Y-%m-%d %H:%M:%S")
if expire_time < datetime.now():
print(f"\n{Fore.YELLOW}[提示] 会员已过期,请续费后重试{Style.RESET_ALL}")
sys.exit(0)
return result
if result['expire_time']:
expire_time = datetime.strptime(result['expire_time'], "%Y-%m-%d %H:%M:%S")
if expire_time < datetime.now():
print(f"\n{Fore.RED}✗ 会员已过期,请续费后重试{Style.RESET_ALL}")
sys.exit(1)
return result
print(f"\n{Fore.RED}✗ 验证失败: {result['msg']}{Style.RESET_ALL}")
retry = get_user_input("是否重试? (y/n):", ['y','n'])
if retry != 'y':
sys.exit(1)
print(f"\n{Fore.YELLOW}[提示] 验证失败: {result['msg']}{Style.RESET_ALL}")
retry = get_user_input("是否重试? (y/n):", ['y','n'])
if retry.lower() != 'y':
print(f"\n{Fore.YELLOW}[提示] 程序已退出{Style.RESET_ALL}")
sys.exit(0)
retry_count += 1
except Exception as e:
if retry_count < max_retries - 1:
print(f"\n{Fore.YELLOW}[提示] 验证过程出现问题,正在重试...{Style.RESET_ALL}")
retry_count += 1
time.sleep(1)
continue
else:
print(f"\n{Fore.YELLOW}[提示] 验证失败次数过多,程序退出{Style.RESET_ALL}")
sys.exit(0)
print(f"\n{Fore.YELLOW}[提示] 验证次数已达上限,程序退出{Style.RESET_ALL}")
sys.exit(0)
def print_status(message, status="info"):
@@ -764,19 +792,31 @@ if __name__ == "__main__":
email=account, access_token=token, refresh_token=token
)
print_status("执行完整重置...")
# 关闭浏览器以释放文件锁
# 先关闭浏览器以释放文件锁
if browser_manager:
browser_manager.quit()
print_status("正在关闭 Cursor...", "info")
if ExitCursor():
print_status("Cursor 已关闭", "success")
else:
print_status("Cursor 关闭失败,继续执行...", "warning")
time.sleep(2) # 等待进程完全退出
# 执行完整重置
from full_reset import full_system_reset
if full_system_reset():
print_status("执行完整重置...")
# 以管理员权限执行完整重置
try:
subprocess.run([
"powershell",
"-Command",
"Start-Process python -ArgumentList 'full_reset.py' -Verb RunAs -Wait"
])
print_status("完整重置成功", "success")
print_status("所有操作已完成", "success")
print(f"\n{Fore.GREEN}✓ 重置完成!下次启动 Cursor 将使用新的配置。{Style.RESET_ALL}")
else:
print_status("完整重置失败", "error")
except Exception as e:
print_status(f"完整重置失败: {str(e)}", "error")
else:
print_status("获取会话令牌失败,注册流程未完成", "error")