diff --git a/config/config.py b/config/config.py index 6804a94..d1dc48c 100644 --- a/config/config.py +++ b/config/config.py @@ -1,7 +1,11 @@ from enum import Enum, auto + +from tool.DownloadPathTool import get_config_path + port = 8426 -priKeySavePath = "./private.pem" -pubKeySavePath = "./public.pem" +configPath = get_config_path() +priKeySavePath = f"{configPath}/private.pem" +pubKeySavePath = f"{configPath}/public.pem" class EncryptType(Enum): AES_ECB = auto() diff --git a/tool/DownloadPathTool.py b/tool/DownloadPathTool.py index b365591..988195a 100644 --- a/tool/DownloadPathTool.py +++ b/tool/DownloadPathTool.py @@ -3,6 +3,18 @@ import sys import winreg from pathlib import Path +def get_config_path(): + if sys.platform == 'win32': + # 展开环境变量并转换为标准格式 + download_dir = Path(os.path.expandvars("%appdata%/fst")).resolve() + else: + # 对于非 Windows 系统,使用 ~\Downloads 作为默认下载目录 + home_dir = Path.home() + download_dir = home_dir / 'fst' + dir_path = Path(download_dir) + if not dir_path.exists(): + dir_path.mkdir(parents=True, exist_ok=True) + return str(download_dir) def get_download_directory(): if sys.platform == 'win32':