2
This commit is contained in:
21
backend/txm/app/config_loader.py
Normal file
21
backend/txm/app/config_loader.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user