From 80aab8741fa826ab286856c0ebfded9cc64ce2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=B5=B7=E9=BE=99?= Date: Thu, 3 Apr 2025 15:42:10 +0800 Subject: [PATCH] feat: Add support for custom Cursor installation paths on Windows - Modify base_path detection to use custom paths from config - Replace forward slashes with backslashes in Windows path definition --- reset_machine_manual.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/reset_machine_manual.py b/reset_machine_manual.py index a10f862..45f6664 100644 --- a/reset_machine_manual.py +++ b/reset_machine_manual.py @@ -159,6 +159,14 @@ def get_cursor_machine_id_path(translator=None) -> str: def get_workbench_cursor_path(translator=None) -> str: """Get Cursor workbench.desktop.main.js path""" system = platform.system() + + # Read configuration + config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip") + config_file = os.path.join(config_dir, "config.ini") + config = configparser.ConfigParser() + + if os.path.exists(config_file): + config.read(config_file) paths_map = { "Darwin": { # macOS @@ -166,8 +174,7 @@ def get_workbench_cursor_path(translator=None) -> str: "main": "out/vs/workbench/workbench.desktop.main.js" }, "Windows": { - "base": os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app"), - "main": "out/vs/workbench/workbench.desktop.main.js" + "main": "out\\vs\\workbench\\workbench.desktop.main.js" }, "Linux": { "bases": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", "/usr/lib/cursor/app/"], @@ -185,7 +192,11 @@ def get_workbench_cursor_path(translator=None) -> str: return main_path raise OSError(translator.get('reset.linux_path_not_found') if translator else "在 Linux 系统上未找到 Cursor 安装路径") - base_path = paths_map[system]["base"] + if system == "Windows": + base_path = config.get('WindowsPaths', 'cursor_path') + else: + base_path = paths_map[system]["base"] + main_path = os.path.join(base_path, paths_map[system]["main"]) if not os.path.exists(main_path):