0
0
mirror of https://github.com/yeongpin/cursor-free-vip.git synced 2025-04-24 08:25:23 +00:00

Update CHANGELOG.md for version 1.9.02 and enhance config handling

- Added entries for version 1.9.02 in CHANGELOG.md, detailing fixes for configuration file path, Windows user permissions, and other issues.
- Improved `config.py` to handle document path retrieval more robustly, including fallback to a temporary directory if the documents path is not found.
- Updated localization files to include new strings for configuration messages in both English and Chinese.
This commit is contained in:
yeongpin 2025-04-12 17:00:18 +08:00
parent 3862176867
commit 26a8e8da28
6 changed files with 51 additions and 9 deletions

4
.env
View File

@ -1,2 +1,2 @@
version=1.9.01
VERSION=1.9.01
version=1.9.02
VERSION=1.9.02

View File

@ -6,7 +6,7 @@ on:
version:
description: 'Version number (e.g. 1.0.9)'
required: true
default: '1.9.01'
default: '1.9.02'
permissions:
contents: write

View File

@ -1,5 +1,10 @@
# Change Log
## v1.9.02
1. Fix: Config File Path | 修復配置文件路徑
2. Fix: window user permission | 修復 window 用戶權限
3. Fix: Some Issues | 修復一些問題
## v1.9.01
1. Add: Bypass Token Limit | 添加繞過 Token 限制
2. Add: More Browser Support | 添加更多瀏覽器支持

View File

@ -18,13 +18,41 @@ EMOJI = {
"SETTINGS": "⚙️"
}
# global config cache
_config_cache = None
def setup_config(translator=None):
"""Setup configuration file and return config object"""
try:
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
config_file = os.path.join(config_dir, "config.ini")
os.makedirs(config_dir, exist_ok=True)
# get documents path
docs_path = get_user_documents_path()
if not docs_path or not os.path.exists(docs_path):
# if documents path not found, use current directory
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.documents_path_not_found', fallback='Documents path not found, using current directory') if translator else 'Documents path not found, using current directory'}{Style.RESET_ALL}")
docs_path = os.path.abspath('.')
# normalize path
config_dir = os.path.normpath(os.path.join(docs_path, ".cursor-free-vip"))
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
# create config directory, only print message when directory not exists
dir_exists = os.path.exists(config_dir)
try:
os.makedirs(config_dir, exist_ok=True)
if not dir_exists: # only print message when directory not exists
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_dir_created', path=config_dir) if translator else f'Config directory created: {config_dir}'}{Style.RESET_ALL}")
except Exception as e:
# if cannot create directory, use temporary directory
import tempfile
temp_dir = os.path.normpath(os.path.join(tempfile.gettempdir(), ".cursor-free-vip"))
temp_exists = os.path.exists(temp_dir)
config_dir = temp_dir
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
os.makedirs(config_dir, exist_ok=True)
if not temp_exists: # only print message when temporary directory not exists
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.using_temp_dir', path=config_dir, error=str(e)) if translator else f'Using temporary directory due to error: {config_dir} (Error: {str(e)})'}{Style.RESET_ALL}")
# create config object
config = configparser.ConfigParser()
# Default configuration
@ -330,4 +358,7 @@ def force_update_config(translator=None):
def get_config(translator=None):
"""Get existing config or create new one"""
return setup_config(translator)
global _config_cache
if _config_cache is None:
_config_cache = setup_config(translator)
return _config_cache

View File

@ -572,7 +572,10 @@
"backup_failed": "Failed to backup config: {error}",
"force_update_failed": "Force update config failed: {error}",
"config_force_update_disabled": "Config file force update disabled , skipping forced update",
"config_force_update_enabled": "Config file force update enabled , performing forced update"
"config_force_update_enabled": "Config file force update enabled , performing forced update",
"documents_path_not_found": "Documents path not found, using current directory",
"config_dir_created": "Config directory created: {path}",
"using_temp_dir": "Using temporary directory due to error: {path} (Error: {error})"
},
"oauth": {
"authentication_button_not_found": "Authentication button not found",

View File

@ -550,7 +550,10 @@
"backup_failed": "备份失败: {error}",
"force_update_failed": "强制更新配置失败: {error}",
"config_force_update_disabled": "配置文件强制更新已禁用,跳过强制更新",
"config_force_update_enabled": "配置文件强制更新已启用,正在执行强制更新"
"config_force_update_enabled": "配置文件强制更新已启用,正在执行强制更新",
"documents_path_not_found": "找不到文档路径,使用当前目录",
"config_dir_created": "已创建配置目录: {path}",
"using_temp_dir": "由于错误使用临时目录: {path} (错误: {error})"
},
"oauth": {
"authentication_button_not_found": "未找到认证按钮",