Merge branch 'yeongpin:main' into main

This commit is contained in:
Luiz Henrique 2025-03-28 00:40:09 -03:00 committed by GitHub
commit 51fcf83ebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 66 additions and 13 deletions

4
.env
View File

@ -1,2 +1,2 @@
version=1.7.17 version=1.7.18
VERSION=1.7.17 VERSION=1.7.18

View File

@ -1,5 +1,11 @@
# Change Log # Change Log
## v1.7.18
1. Fix: No Write Permission | 修復沒有寫入權限
2. Fix: Improve Linux path detection and config handling 修正 linux 路徑和config寫入讀取
3. Fix: Locale path_no_exist missing 修正 path_no_exist 語言遺失
4. Fix: Some Issues | 修復一些問題
## v1.7.17 ## v1.7.17
1. Fix: Remove 10 options Totally Reset Cursor | 修復完全重置 Cursor 選項 1. Fix: Remove 10 options Totally Reset Cursor | 修復完全重置 Cursor 選項

View File

@ -103,8 +103,9 @@
"package_not_found": "Package.json Not Found: {path}", "package_not_found": "Package.json Not Found: {path}",
"check_version_failed": "Check Version Failed: {error}", "check_version_failed": "Check Version Failed: {error}",
"stack_trace": "Stack Trace", "stack_trace": "Stack Trace",
"version_too_low": "Cursor Version Too Low: {version} < 0.45.0" "version_too_low": "Cursor Version Too Low: {version} < 0.45.0",
"no_write_permission": "No Write Permission: {path}",
"path_not_found": "Path Not Found: {path}"
}, },
"register": { "register": {
"title": "Cursor Registration Tool", "title": "Cursor Registration Tool",

View File

@ -103,7 +103,9 @@
"package_not_found": "package.json未找到: {path}", "package_not_found": "package.json未找到: {path}",
"check_version_failed": "检查版本失败: {error}", "check_version_failed": "检查版本失败: {error}",
"stack_trace": "堆栈跟踪", "stack_trace": "堆栈跟踪",
"version_too_low": "Cursor版本太低: {version} < 0.45.0" "version_too_low": "Cursor版本太低: {version} < 0.45.0",
"no_write_permission": "没有写入权限: {path}",
"path_not_found": "路径未找到: {path}"
}, },
"register": { "register": {
"title": "Cursor 注册工具", "title": "Cursor 注册工具",

View File

@ -101,7 +101,9 @@
"package_not_found": "package.json未找到: {path}", "package_not_found": "package.json未找到: {path}",
"check_version_failed": "檢查版本失敗: {error}", "check_version_failed": "檢查版本失敗: {error}",
"stack_trace": "堆疊跟踪", "stack_trace": "堆疊跟踪",
"version_too_low": "Cursor版本太低: {version} < 0.45.0" "version_too_low": "Cursor版本太低: {version} < 0.45.0",
"no_write_permission": "沒有寫入權限: {path}",
"path_not_found": "路徑未找到: {path}"
}, },
"register": { "register": {

View File

@ -83,7 +83,7 @@ muhammedfurkan plamkatawe
""" """
OTHER_INFO_TEXT = f"""{Fore.YELLOW} OTHER_INFO_TEXT = f"""{Fore.YELLOW}
Github: https://github.com/yeongpin/cursor-free-vip{Fore.RED} Github: https://github.com/yeongpin/cursor-free-vip{Fore.RED}
Press 7 to change language | 按下 7 键切换语言{Style.RESET_ALL}""" Press 8 to change language | 按下 8 键切换语言{Style.RESET_ALL}"""
# center display LOGO and DESCRIPTION # center display LOGO and DESCRIPTION
CURSOR_LOGO = center_multiline_text(LOGO_TEXT, handle_chinese=False) CURSOR_LOGO = center_multiline_text(LOGO_TEXT, handle_chinese=False)
@ -98,4 +98,4 @@ def print_logo():
print(CURSOR_OTHER_INFO) print(CURSOR_OTHER_INFO)
if __name__ == "__main__": if __name__ == "__main__":
print_logo() print_logo()

View File

@ -37,10 +37,41 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip") config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
config_file = os.path.join(config_dir, "config.ini") config_file = os.path.join(config_dir, "config.ini")
# Create config directory if it doesn't exist
if not os.path.exists(config_dir):
os.makedirs(config_dir)
# Default paths for different systems
default_paths = {
"Darwin": "/Applications/Cursor.app/Contents/Resources/app",
"Windows": os.path.join(os.getenv("LOCALAPPDATA", ""), "Programs", "Cursor", "resources", "app"),
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")]
}
# If config doesn't exist, create it with default paths
if not os.path.exists(config_file): if not os.path.exists(config_file):
raise OSError(translator.get('reset.config_not_found') if translator else "找不到配置文件") for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']:
if not config.has_section(section):
config.add_section(section)
config.read(config_file, encoding='utf-8') # Specify encoding if system == "Darwin":
config.set('MacPaths', 'cursor_path', default_paths["Darwin"])
elif system == "Windows":
config.set('WindowsPaths', 'cursor_path', default_paths["Windows"])
elif system == "Linux":
# For Linux, try to find the first existing path
for path in default_paths["Linux"]:
if os.path.exists(path):
config.set('LinuxPaths', 'cursor_path', path)
break
else:
# If no path exists, use the first one as default
config.set('LinuxPaths', 'cursor_path', default_paths["Linux"][0])
with open(config_file, 'w', encoding='utf-8') as f:
config.write(f)
else:
config.read(config_file, encoding='utf-8')
# Get path based on system # Get path based on system
if system == "Darwin": if system == "Darwin":
@ -51,15 +82,26 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
section = 'LinuxPaths' section = 'LinuxPaths'
else: else:
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}") raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
if not config.has_section(section) or not config.has_option(section, 'cursor_path'): if not config.has_section(section) or not config.has_option(section, 'cursor_path'):
raise OSError(translator.get('reset.path_not_configured') if translator else "未配置 Cursor 路徑") raise OSError(translator.get('reset.path_not_configured') if translator else "未配置 Cursor 路徑")
base_path = config.get(section, 'cursor_path') base_path = config.get(section, 'cursor_path')
# For Linux, try to find the first existing path if the configured one doesn't exist
if system == "Linux" and not os.path.exists(base_path):
for path in default_paths["Linux"]:
if os.path.exists(path):
base_path = path
# Update config with the found path
config.set(section, 'cursor_path', path)
with open(config_file, 'w', encoding='utf-8') as f:
config.write(f)
break
if not os.path.exists(base_path): if not os.path.exists(base_path):
raise OSError(translator.get('reset.path_not_found', path=base_path) if translator else f"找不到 Cursor 路徑: {base_path}") raise OSError(translator.get('reset.path_not_found', path=base_path) if translator else f"找不到 Cursor 路徑: {base_path}")
pkg_path = os.path.join(base_path, "package.json") pkg_path = os.path.join(base_path, "package.json")
main_path = os.path.join(base_path, "out/main.js") main_path = os.path.join(base_path, "out/main.js")