import os from pydantic_settings import BaseSettings, SettingsConfigDict def _local_dev_default() -> bool: """非生产机默认开本地调试;生产设 NOMADRO_ENV=production。""" return os.getenv("NOMADRO_ENV", "").lower() not in {"prod", "production"} class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") app_name: str = "nomadmini-api" # 本地默认开;生产用 NOMADRO_ENV=production 或 DEBUG=false debug: bool = _local_dev_default() api_host: str = "0.0.0.0" api_port: int = 8000 public_api_base: str = "https://api.nomadro.cn" admin_origin: str = "https://admin.nomadro.cn" cors_origins: str = ( "https://admin.nomadro.cn,https://nomadro.cn,https://www.nomadro.cn," "http://localhost:5173,http://127.0.0.1:5173,http://localhost:3000,http://127.0.0.1:3000" ) # WeChat 虚拟支付(AppID wx11f6afc44ea1532f · OfferID 1450705308) wx_appid: str = "wx11f6afc44ea1532f" wx_secret: str = "04214ecc910dca4526781c90bae94da1" wx_offer_id: str = "1450705308" wx_app_key: str = "JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY" # 现网 wx_sandbox_app_key: str = "BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi" # 沙箱 wx_pay_env: int = 0 # 0 现网 / 1 沙箱 # JWT / Admin jwt_secret: str = "nomadro-jwt-local-dev-2026" admin_username: str = "hackrobot" admin_password: str = "Xiao4669805@" # PocketBase pb_url: str = "http://127.0.0.1:8090" pb_admin_email: str = "admin@nomadro.cn" pb_admin_password: str = "Xiao4669805" use_pocketbase: bool = False sqlite_path: str = "../data/nomadmini.db" # Web VIP 桥接(vip.hackrobot.cn ↔ 小程序)— 默认关,避免误伤线上 # 开启:环境变量 VIP_WEB_BRIDGE_ENABLED=true vip_web_bridge_enabled: bool = False vip_web_api_base: str = "https://vip.hackrobot.cn" # 可选:代理 vip.hackrobot.cn/api/wechat-users(运营台 token);空则自动登录 ops vip_ops_token: str = "" vip_ops_login_url: str = "https://admin.hackrobot.cn/api/ops/login" vip_ops_username: str = "hackrobot" vip_ops_password: str = "Xiao4669805@" # 抖音 platforms.tt 写入路径(默认自动探测门户 remote-config.json) tt_remote_config_path: str = "" default_product_id: str = "youtube" default_price_fen: int = 18800 default_unlock_percent: int = 30 wx_push_token: str = "hackrobot" wx_push_encoding_aes_key: str = "ulnyydH8LF4uWmdpzSgUiWS6hVXp1V3wp26MhEYeHkI" # 本地默认开;生产 NOMADRO_ENV=production 时默认关 wx_allow_devtools_login: bool = _local_dev_default() # ntfy(自建 https://ntfy.nomadro.cn) ntfy_enabled: bool = True ntfy_base_url: str = "http://127.0.0.1:2586" # 机内直连,避免自签/回环 HTTPS ntfy_topic: str = "nomadmini" ntfy_token: str = "" settings = Settings()