fix: align resource and runtime paths
This commit is contained in:
@@ -174,3 +174,8 @@ cython_debug/
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Runtime data
|
||||
config/
|
||||
logs/
|
||||
output/
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 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):
|
||||
|
||||
Reference in New Issue
Block a user