xxx
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from typing import Dict
|
||||
from typing import Dict, Tuple, Any
|
||||
from PyQt5.QtWidgets import (
|
||||
QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
|
||||
QMessageBox, QLabel, QLineEdit, QPushButton,
|
||||
@@ -11,6 +11,7 @@ from PyQt5.QtGui import QFont, QIcon, QDesktopServices
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
from services.cursor_service import CursorService
|
||||
from gui.components.widgets import (
|
||||
@@ -90,26 +91,34 @@ class InstructionsWidget(QFrame):
|
||||
|
||||
# 步骤说明
|
||||
steps = [
|
||||
("第一步", "输入激活码点击【激活】按钮完成激活"),
|
||||
("第二步", "点击【刷新Cursor编辑器授权】,一般情况下刷新即可正常使用"),
|
||||
("如果无法对话", "点击【实现Cursor0.45.x限制】,然后重新刷新授权"),
|
||||
("建议操作", "点击【禁用Cursor版本更新】,保持软件稳定运行")
|
||||
("初次使用", "输入激活码点击【激活】按钮完成激活(一个激活码只能用一次)"),
|
||||
("日常使用说明", "点击【刷新Cursor编辑器授权】,重启编辑器打开新的chat对话窗口 "),
|
||||
("代理及对接号池", " 全球动态代理高品质号。不降智可使用3.7thinkingpro一样体验https://cursorpro.com.cn"),
|
||||
# ("账号问题", "出现3.7拥挤或者vpn、ip等均不是账号问题 重启编辑器或者new新chat或者切换代理路线即可 切勿多次刷新账号\n"
|
||||
# "现在账号紧缺后台防止盗号有限制供日常重度使用也是够的账号。\n"
|
||||
# "如果账号问题可以联系我处理"),
|
||||
# ("建议操作", "点击【禁用Cursor版本更新】,个别机型因为权限无法禁用这个不影响使用")
|
||||
]
|
||||
|
||||
for step_title, step_content in steps:
|
||||
for i, (step_title, step_content) in enumerate(steps):
|
||||
step_label = QLabel(f"{step_title}:{step_content}")
|
||||
step_label.setWordWrap(True)
|
||||
label_color = "#181818" if i == len(steps)-1 else "#495057"
|
||||
step_label.setStyleSheet("""
|
||||
QLabel {
|
||||
color: #495057;
|
||||
color: {label_color};
|
||||
margin: 3px 0;
|
||||
min-height: 15px;
|
||||
line-height: 15px;
|
||||
}
|
||||
""")
|
||||
layout.addWidget(step_label)
|
||||
|
||||
# 给标题部分添加颜色
|
||||
text = step_label.text()
|
||||
step_label.setText(f'<span style="color: #17a2b8;">{step_title}</span>:{step_content}')
|
||||
# 最后一个标题标红,其他保持原来的青色
|
||||
title_color = "#e0a800" if i == len(steps)-1 else "#17a2b8"
|
||||
step_label.setText(f'<span style="color: {title_color};">{step_title}</span>:{step_content}')
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
"""主窗口"""
|
||||
@@ -125,8 +134,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setup_ui()
|
||||
|
||||
# 移除直接自检
|
||||
# self.auto_check()
|
||||
|
||||
|
||||
def setup_tray(self):
|
||||
"""初始化托盘图标"""
|
||||
@@ -237,7 +245,24 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def setup_ui(self):
|
||||
"""初始化UI"""
|
||||
self.setWindowTitle(f"听泉助手 v{get_current_version()}")
|
||||
# 获取 Cursor 版本
|
||||
cursor_version = "未知"
|
||||
try:
|
||||
package_paths = [
|
||||
os.path.join(os.getenv('LOCALAPPDATA'), 'Programs', 'cursor', 'resources', 'app', 'package.json'),
|
||||
os.path.join(os.getenv('LOCALAPPDATA'), 'cursor', 'resources', 'app', 'package.json')
|
||||
]
|
||||
|
||||
for path in package_paths:
|
||||
if os.path.exists(path):
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
cursor_version = data.get('version', '未知')
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"获取 Cursor 版本失败: {e}")
|
||||
|
||||
self.setWindowTitle(f"听泉助手 v{get_current_version()} (本机Cursor版本{cursor_version})")
|
||||
self.setMinimumSize(600, 500)
|
||||
|
||||
# 设置窗口图标
|
||||
@@ -291,9 +316,11 @@ class MainWindow(QMainWindow):
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
font-size: 15px;
|
||||
min-height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #0056b3;
|
||||
@@ -323,8 +350,9 @@ class MainWindow(QMainWindow):
|
||||
background-color: #ccc;
|
||||
}
|
||||
""")
|
||||
button_layout.addWidget(self.limit_button)
|
||||
|
||||
# button_layout.addWidget(self.limit_button)
|
||||
|
||||
|
||||
# 禁用更新按钮 - 红色
|
||||
self.disable_button = QPushButton("禁用 Cursor 版本更新")
|
||||
self.disable_button.clicked.connect(lambda: self.start_task('disable'))
|
||||
@@ -333,9 +361,11 @@ class MainWindow(QMainWindow):
|
||||
background-color: #dc3545;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
min-height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #c82333;
|
||||
@@ -346,7 +376,33 @@ class MainWindow(QMainWindow):
|
||||
""")
|
||||
button_layout.addWidget(self.disable_button)
|
||||
|
||||
|
||||
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
# 购买链接按钮
|
||||
self.purchase_button = QPushButton("购买(代理产品)激活码")
|
||||
self.purchase_button.clicked.connect(self.open_purchase_link)
|
||||
self.purchase_button.setStyleSheet("""
|
||||
QPushButton {
|
||||
background-color: #ffc107;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
min-height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #e0a800;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #ccc;
|
||||
}
|
||||
""")
|
||||
button_layout.addWidget(self.purchase_button)
|
||||
|
||||
# 检查更新按钮 - 灰色
|
||||
self.check_update_button = QPushButton("检查更新")
|
||||
@@ -475,37 +531,99 @@ class MainWindow(QMainWindow):
|
||||
"""更新进度信息"""
|
||||
self.status_bar.set_status(info.get('message', '处理中...'))
|
||||
|
||||
def handle_result(self, result: tuple):
|
||||
"""处理任务结果"""
|
||||
task_type, data = result
|
||||
success, msg = data if isinstance(data, tuple) else (False, str(data))
|
||||
def show_solution_dialog(self) -> None:
|
||||
"""显示通用解决方案对话框"""
|
||||
solution_msg = (
|
||||
"请按照以下步骤操作:\n\n"
|
||||
"1. 以管理员身份运行 PowerShell\n"
|
||||
"2. 复制并运行以下命令:\n\n"
|
||||
"irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/maticarmy/cursor-nosqli-tools/refs/heads/main/scripts/run/cursor_win_id_modifier.ps1 | iex\n\n"
|
||||
"是否复制此命令到剪贴板?"
|
||||
)
|
||||
|
||||
if success:
|
||||
QMessageBox.information(self, "成功", msg)
|
||||
else:
|
||||
QMessageBox.warning(self, "失败", msg)
|
||||
reply = QMessageBox.question(
|
||||
self,
|
||||
"解决方案",
|
||||
solution_msg,
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
QMessageBox.Yes
|
||||
)
|
||||
|
||||
# 重新启用按钮
|
||||
self.update_member_status()
|
||||
self.status_bar.set_status("就绪")
|
||||
if reply == QMessageBox.Yes:
|
||||
clipboard = QApplication.clipboard()
|
||||
clipboard.setText("irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/maticarmy/cursor-nosqli-tools/refs/heads/main/scripts/run/cursor_win_id_modifier.ps1 | iex")
|
||||
QMessageBox.information(self, "成功", "命令已复制到剪贴板")
|
||||
|
||||
def show_error_with_solution(self, title: str, message: str) -> None:
|
||||
"""显示带有解决方案按钮的错误对话框
|
||||
:param title: 对话框标题
|
||||
:param message: 错误信息
|
||||
"""
|
||||
msg_box = QMessageBox(self)
|
||||
msg_box.setIcon(QMessageBox.Warning)
|
||||
msg_box.setWindowTitle(title)
|
||||
msg_box.setText(message)
|
||||
|
||||
# 清理工作线程
|
||||
if self.current_worker:
|
||||
self.current_worker.stop()
|
||||
self.current_worker = None
|
||||
|
||||
# 添加解决方案按钮
|
||||
solution_button = msg_box.addButton("解决方案", QMessageBox.ActionRole)
|
||||
msg_box.addButton("关闭", QMessageBox.RejectRole)
|
||||
|
||||
msg_box.exec_()
|
||||
|
||||
# 如果点击了解决方案按钮
|
||||
if msg_box.clickedButton() == solution_button:
|
||||
self.show_solution_dialog()
|
||||
|
||||
def handle_result(self, result: Tuple[str, Any]):
|
||||
"""处理工作线程的结果"""
|
||||
try:
|
||||
self.hide_loading()
|
||||
action, data = result
|
||||
|
||||
if action == 'reset':
|
||||
success, msg, _ = data
|
||||
if success:
|
||||
self.status_bar.set_status("重置成功")
|
||||
QMessageBox.information(self, "成功", msg)
|
||||
else:
|
||||
self.status_bar.set_status("重置失败")
|
||||
self.show_error_with_solution("操作失败", msg)
|
||||
|
||||
elif action == 'disable':
|
||||
success, msg = data
|
||||
if success:
|
||||
self.status_bar.set_status("禁用更新成功")
|
||||
QMessageBox.information(self, "成功", msg)
|
||||
else:
|
||||
self.status_bar.set_status("禁用更新失败")
|
||||
self.show_error_with_solution("操作失败", msg)
|
||||
|
||||
elif action == 'refresh':
|
||||
success, msg = data
|
||||
if success:
|
||||
self.status_bar.set_status("刷新成功")
|
||||
QMessageBox.information(self, "成功", msg)
|
||||
else:
|
||||
self.status_bar.set_status("刷新失败")
|
||||
self.show_error_with_solution("操作失败", msg)
|
||||
except Exception as e:
|
||||
self.logger.error(f"处理结果时出错: {str(e)}")
|
||||
self.status_bar.set_status("处理结果时出错")
|
||||
finally:
|
||||
# 恢复按钮状态
|
||||
self.update_member_status() # 确保按钮状态恢复
|
||||
|
||||
def handle_error(self, error_msg: str):
|
||||
"""处理错误"""
|
||||
self.status_bar.set_status("发生错误")
|
||||
QMessageBox.critical(self, "错误", f"操作失败:{error_msg}")
|
||||
|
||||
# 重新启用按钮
|
||||
self.update_member_status()
|
||||
self.update_member_status() # 确保按钮状态恢复
|
||||
|
||||
# 清理工作线程
|
||||
if self.current_worker:
|
||||
self.current_worker.stop()
|
||||
self.current_worker = None
|
||||
|
||||
def check_update(self):
|
||||
"""手动检查更新"""
|
||||
@@ -664,4 +782,8 @@ class MainWindow(QMainWindow):
|
||||
# 停止所有正在运行的任务
|
||||
if self.current_worker:
|
||||
self.current_worker.stop()
|
||||
event.accept()
|
||||
event.accept()
|
||||
|
||||
def open_purchase_link(self):
|
||||
"""打开购买链接"""
|
||||
self.activation_widget.show_activation_required()
|
||||
|
||||
Reference in New Issue
Block a user