fix: align resource and runtime paths

This commit is contained in:
2026-06-15 17:13:36 +08:00
parent 519bb9a6d2
commit a6a8504ea8
3 changed files with 20 additions and 5 deletions
+7 -3
View File
@@ -15,10 +15,14 @@ _CONFIG_FILENAME = "app_config.json"
def load_config():
"""Load app config from JSON. Returns defaults merged with file values.
"""
从 JSON 文件加载应用配置。
Never raises: missing file → info log + defaults;
damaged file → warning log + defaults.
返回默认配置与文件配置的合并字典。如果配置文件不存在、损坏或无法读取,
函数不会抛出异常,而是记录日志并返回默认配置。
Returns:
dict: 合并后的配置字典
"""
from services.file_service import get_config_path
config_file = get_config_path(_CONFIG_FILENAME)
+8 -2
View File
@@ -30,8 +30,14 @@ def get_app_dir():
def get_resource_path(relative_path):
"""Return absolute Path for a file under <app_dir>/resources/."""
return get_app_dir() / "resources" / relative_path
"""Return absolute Path for a resource file.
Development resources live under src/resources/. In a PyInstaller onedir
build, resources are copied next to the executable under resources/.
"""
if getattr(sys, "frozen", False):
return get_app_dir() / "resources" / relative_path
return get_app_dir() / "src" / "resources" / relative_path
def get_config_path(relative_path):