Files
PartsInquiry/backend/txm/app/config_loader.py
2025-09-27 22:57:59 +08:00

22 lines
686 B
Python

import os
import platform
from typing import Any, Dict
import yaml
def load_config(config_path: str = "config/config.yaml") -> Dict[str, Any]:
with open(config_path, "r", encoding="utf-8") as f:
config = yaml.safe_load(f)
# 动态选择中文字体
sys_name = platform.system().lower()
if sys_name.startswith("win"):
config.setdefault("font", {})["selected"] = config["font"].get("windows")
elif sys_name.startswith("darwin") or sys_name.startswith("mac"):
config.setdefault("font", {})["selected"] = config["font"].get("macos")
else:
config.setdefault("font", {})["selected"] = config["font"].get("linux")
return config