diff --git a/account_switcher.py b/account_switcher.py index c0ef5f8..5bc2176 100644 --- a/account_switcher.py +++ b/account_switcher.py @@ -570,6 +570,49 @@ class AccountSwitcher: logging.error(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(): """主函数""" try: diff --git a/gui/main_window.py b/gui/main_window.py index 7c4b08d..968fb75 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -124,7 +124,7 @@ class MainWindow: 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="突破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): """复制设备ID到剪贴板""" @@ -223,10 +223,7 @@ class MainWindow: self.status_text.config(state="disabled") def check_status(self): - """检查会员状态 - Returns: - bool: True 表示激活状态正常,False 表示未激活或已过期 - """ + """检查会员状态""" try: self.status_var.set("正在检查状态...") self.root.update() @@ -235,7 +232,6 @@ class MainWindow: if status: self.update_status_display(status) if status.get('status') == 'inactive': - messagebox.showwarning("警告", "当前设备未激活或激活已失效") self.status_var.set("未激活") return False self.status_var.set("状态检查完成") @@ -245,23 +241,74 @@ class MainWindow: inactive_status = { "hardware_id": self.switcher.hardware_id, "expire_time": "", - "days": 0, + "days_left": 0, "total_days": 0, "status": "inactive", - "last_activation": {} + "activation_records": [] } self.update_status_display(inactive_status) self.status_var.set("未激活") - messagebox.showwarning("警告", "当前设备未激活") return False except Exception as e: logging.error(f"检查状态失败: {str(e)}") self.status_var.set("状态检查失败") - # 显示错误消息 messagebox.showerror("错误", f"检查状态失败: {str(e)}") 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): """最小化窗口""" self.root.iconify() @@ -301,10 +348,40 @@ class MainWindow: """运行程序""" 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): """突破版本限制""" - # 先检查状态 if not self.check_status(): + self.show_purchase_info() return try: @@ -314,16 +391,4 @@ class MainWindow: else: messagebox.showerror("错误", message) except Exception as 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)}") \ No newline at end of file + messagebox.showerror("错误", f"操作失败: {str(e)}") \ No newline at end of file diff --git a/version.txt b/version.txt index b38ebbf..489200c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.0.4 \ No newline at end of file +3.0.9 \ No newline at end of file