更新: 1. 优化未激活状态下的购买信息提示框 2. 添加一键复制功能 3. 更新版本到3.0.9

This commit is contained in:
huangzhenpc
2025-02-12 11:23:29 +08:00
parent 0435e586ab
commit 716b2dc47b
3 changed files with 133 additions and 25 deletions

View File

@@ -570,6 +570,49 @@ class AccountSwitcher:
logging.error(f"刷新授权过程出错: {str(e)}") logging.error(f"刷新授权过程出错: {str(e)}")
return False, f"刷新失败: {str(e)}" return False, f"刷新失败: {str(e)}"
def disable_cursor_update(self) -> Tuple[bool, str]:
"""禁用Cursor更新"""
try:
# 1. 先关闭所有Cursor进程
if sys.platform == "win32":
os.system("taskkill /f /im Cursor.exe >nul 2>&1")
time.sleep(2)
# 2. 删除updater目录并创建同名文件以阻止更新
updater_path = Path(os.getenv('LOCALAPPDATA')) / "cursor-updater"
try:
# 如果是目录,则删除
if updater_path.is_dir():
import shutil
shutil.rmtree(str(updater_path))
logging.info("删除updater目录成功")
# 如果是文件,则删除
if updater_path.is_file():
os.remove(str(updater_path))
logging.info("删除updater文件成功")
# 创建同名空文件
updater_path.touch()
logging.info("创建updater空文件成功")
# 3. 重启Cursor
cursor_exe = self.cursor_path / "Cursor.exe"
if cursor_exe.exists():
os.startfile(str(cursor_exe))
logging.info("Cursor重启成功")
return True, "Cursor更新已禁用程序已重启"
except Exception as e:
logging.error(f"操作updater文件失败: {str(e)}")
return False, f"禁用更新失败: {str(e)}"
except Exception as e:
logging.error(f"禁用Cursor更新失败: {str(e)}")
return False, f"禁用更新失败: {str(e)}"
def main(): def main():
"""主函数""" """主函数"""
try: try:

View File

@@ -124,7 +124,7 @@ class MainWindow:
self.style.configure("Action.TButton", padding=8) self.style.configure("Action.TButton", padding=8)
ttk.Button(btn_frame, text="刷新Cursor编辑器授权", command=self.reset_machine_id, style="Action.TButton").pack(fill="x", pady=2) ttk.Button(btn_frame, text="刷新Cursor编辑器授权", command=self.reset_machine_id, style="Action.TButton").pack(fill="x", pady=2)
ttk.Button(btn_frame, text="突破Cursor0.45.x限制", command=self.dummy_function, style="Action.TButton").pack(fill="x", pady=2) ttk.Button(btn_frame, text="突破Cursor0.45.x限制", command=self.dummy_function, style="Action.TButton").pack(fill="x", pady=2)
ttk.Button(btn_frame, text="禁用Cursor版本更新", command=self.dummy_function, style="Action.TButton").pack(fill="x", pady=2) ttk.Button(btn_frame, text="禁用Cursor版本更新", command=self.disable_cursor_update, style="Action.TButton").pack(fill="x", pady=2)
def copy_device_id(self): def copy_device_id(self):
"""复制设备ID到剪贴板""" """复制设备ID到剪贴板"""
@@ -223,10 +223,7 @@ class MainWindow:
self.status_text.config(state="disabled") self.status_text.config(state="disabled")
def check_status(self): def check_status(self):
"""检查会员状态 """检查会员状态"""
Returns:
bool: True 表示激活状态正常False 表示未激活或已过期
"""
try: try:
self.status_var.set("正在检查状态...") self.status_var.set("正在检查状态...")
self.root.update() self.root.update()
@@ -235,7 +232,6 @@ class MainWindow:
if status: if status:
self.update_status_display(status) self.update_status_display(status)
if status.get('status') == 'inactive': if status.get('status') == 'inactive':
messagebox.showwarning("警告", "当前设备未激活或激活已失效")
self.status_var.set("未激活") self.status_var.set("未激活")
return False return False
self.status_var.set("状态检查完成") self.status_var.set("状态检查完成")
@@ -245,23 +241,74 @@ class MainWindow:
inactive_status = { inactive_status = {
"hardware_id": self.switcher.hardware_id, "hardware_id": self.switcher.hardware_id,
"expire_time": "", "expire_time": "",
"days": 0, "days_left": 0,
"total_days": 0, "total_days": 0,
"status": "inactive", "status": "inactive",
"last_activation": {} "activation_records": []
} }
self.update_status_display(inactive_status) self.update_status_display(inactive_status)
self.status_var.set("未激活") self.status_var.set("未激活")
messagebox.showwarning("警告", "当前设备未激活")
return False return False
except Exception as e: except Exception as e:
logging.error(f"检查状态失败: {str(e)}") logging.error(f"检查状态失败: {str(e)}")
self.status_var.set("状态检查失败") self.status_var.set("状态检查失败")
# 显示错误消息
messagebox.showerror("错误", f"检查状态失败: {str(e)}") messagebox.showerror("错误", f"检查状态失败: {str(e)}")
return False return False
def show_purchase_info(self):
"""显示购买信息"""
# 创建自定义对话框
dialog = tk.Toplevel(self.root)
dialog.title("提示")
dialog.geometry("400x280") # 增加高度
dialog.resizable(False, False)
# 设置模态
dialog.transient(self.root)
dialog.grab_set()
# 创建提示图标
icon_frame = ttk.Frame(dialog)
icon_frame.pack(pady=10)
ttk.Label(icon_frame, text="", font=("Segoe UI", 24)).pack()
# 创建消息文本
message_frame = ttk.Frame(dialog)
message_frame.pack(pady=5, padx=20)
ttk.Label(message_frame, text="您还不是会员,请先购买激活会员用讯。", font=("Microsoft YaHei UI", 10)).pack()
# 创建可复制的文本框
buy_info = "闲鱼xxxx\n微信behikcigar\n网站自助购买nezhacursor.nosqli.com"
text = tk.Text(dialog, height=4, width=40, font=("Microsoft YaHei UI", 9))
text.pack(pady=5, padx=20)
text.insert("1.0", buy_info)
text.config(state="normal") # 允许选择和复制
# 创建按钮框架
btn_frame = ttk.Frame(dialog)
btn_frame.pack(pady=10)
# 复制按钮
def copy_info():
dialog.clipboard_clear()
dialog.clipboard_append(buy_info)
messagebox.showinfo("提示", "购买信息已复制到剪贴板", parent=dialog)
ttk.Button(btn_frame, text="复制信息", command=copy_info).pack(side="left", padx=5)
ttk.Button(btn_frame, text="确定", command=dialog.destroy).pack(side="left", padx=5)
# 设置对话框位置为居中
dialog.update_idletasks()
width = dialog.winfo_width()
height = dialog.winfo_height()
x = (dialog.winfo_screenwidth() // 2) - (width // 2)
y = (dialog.winfo_screenheight() // 2) - (height // 2)
dialog.geometry(f"{width}x{height}+{x}+{y}")
# 等待对话框关闭
self.root.wait_window(dialog)
def minimize_window(self): def minimize_window(self):
"""最小化窗口""" """最小化窗口"""
self.root.iconify() self.root.iconify()
@@ -301,10 +348,40 @@ class MainWindow:
"""运行程序""" """运行程序"""
self.root.mainloop() self.root.mainloop()
def reset_machine_id(self):
"""刷新Cursor编辑器授权"""
if not self.check_status():
self.show_purchase_info()
return
try:
success, message = self.switcher.refresh_cursor_auth()
if success:
messagebox.showinfo("成功", "Cursor编辑器授权刷新成功\n" + message)
else:
messagebox.showerror("错误", message)
except Exception as e:
messagebox.showerror("错误", f"刷新失败: {str(e)}")
def disable_cursor_update(self):
"""禁用Cursor版本更新"""
if not self.check_status():
self.show_purchase_info()
return
try:
success, message = self.switcher.disable_cursor_update()
if success:
messagebox.showinfo("成功", message)
else:
messagebox.showerror("错误", message)
except Exception as e:
messagebox.showerror("错误", f"操作失败: {str(e)}")
def dummy_function(self): def dummy_function(self):
"""突破版本限制""" """突破版本限制"""
# 先检查状态
if not self.check_status(): if not self.check_status():
self.show_purchase_info()
return return
try: try:
@@ -314,16 +391,4 @@ class MainWindow:
else: else:
messagebox.showerror("错误", message) messagebox.showerror("错误", message)
except Exception as e: except Exception as e:
messagebox.showerror("错误", f"操作失败: {str(e)}") messagebox.showerror("错误", f"操作失败: {str(e)}")
def reset_machine_id(self):
"""刷新Cursor编辑器授权"""
try:
# 刷新授权
success, message = self.switcher.refresh_cursor_auth()
if success:
messagebox.showinfo("成功", "Cursor编辑器授权刷新成功\n" + message)
else:
messagebox.showerror("错误", message)
except Exception as e:
messagebox.showerror("错误", f"刷新失败: {str(e)}")

View File

@@ -1 +1 @@
3.0.4 3.0.9