feat: Refactor Project Structure and Add Configuration Management

- Add `config.py` for centralized configuration management
- Add `utils.py` for cross-platform utility functions
- Remove `browser.py` and `control.py` to simplify project structure
- Update version to 1.7.06
- Modify build specification to reflect new file structure
- Update localization files with new update confirmation messages
- Enhance configuration loading and path detection across different platforms
This commit is contained in:
yeongpin
2025-03-11 11:49:17 +08:00
parent 6ca80ccb10
commit ff358588bb
18 changed files with 303 additions and 484 deletions

View File

@@ -13,6 +13,7 @@ from typing import Tuple
import configparser
from new_signup import get_user_documents_path
import traceback
from config import get_config
# Initialize colorama
init()
@@ -39,7 +40,7 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
if not os.path.exists(config_file):
raise OSError(translator.get('reset.config_not_found') if translator else "找不到配置文件")
config.read(config_file)
config.read(config_file, encoding='utf-8') # 指定編碼
# 根據系統獲取路徑
if system == "Darwin":
@@ -408,7 +409,7 @@ class MachineIDResetter:
if not os.path.exists(config_file):
raise FileNotFoundError(f"Config file not found: {config_file}")
config.read(config_file)
config.read(config_file, encoding='utf-8')
# Check operating system
if sys.platform == "win32": # Windows
@@ -690,7 +691,9 @@ class MachineIDResetter:
return False
def run(translator=None):
"""Convenient function for directly calling the reset function"""
config = get_config(translator)
if not config:
return False
print(f"\n{Fore.CYAN}{'='*50}{Style.RESET_ALL}")
print(f"{Fore.CYAN}{EMOJI['RESET']} {translator.get('reset.title')}{Style.RESET_ALL}")
print(f"{Fore.CYAN}{'='*50}{Style.RESET_ALL}")