34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from typing import Optional, Union, List
|
|||
|
|
from pydantic import BaseModel, validator
|
||
|
|
|
||
|
|
|
||
|
|
class Config(BaseModel):
|
||
|
|
steam_api_key: Union[str, List[str]]
|
||
|
|
proxy: Optional[str] = None
|
||
|
|
steam_request_interval: int = 300 # seconds
|
||
|
|
steam_broadcast_type: str = "part" # all, part, none
|
||
|
|
steam_disable_broadcast_on_startup: bool = False
|
||
|
|
steam_font_regular_path: Optional[str] = "hexi/resource/fonts/MiSans-Regular.ttf"
|
||
|
|
steam_font_light_path: Optional[str] = "hexi/resource/fonts/MiSans-Light.ttf"
|
||
|
|
steam_font_bold_path: Optional[str] = "hexi/resource/fonts/MiSans-Bold.ttf"
|
||
|
|
|
||
|
|
# 仅用于迁移旧 JSON 状态文件(运行时 API key 状态已持久化到 SQLite)
|
||
|
|
steam_api_key_state_path: Optional[str] = "hexi/data/api_keys_state.json"
|
||
|
|
|
||
|
|
# 游玩时长表图片主题: light / dark,默认亮色
|
||
|
|
steam_playtime_theme: str = "light"
|
||
|
|
|
||
|
|
@validator("steam_playtime_theme")
|
||
|
|
def check_theme(cls, v):
|
||
|
|
v = (v or "light").strip().lower()
|
||
|
|
if v not in ("light", "dark"):
|
||
|
|
raise ValueError("steam_playtime_theme 只能是 light 或 dark")
|
||
|
|
return v
|
||
|
|
|
||
|
|
@validator("steam_api_key", pre=True)
|
||
|
|
def ensure_list(cls, v):
|
||
|
|
if isinstance(v, str):
|
||
|
|
return [v]
|
||
|
|
return v
|
||
|
|
|