""" 应用配置 """ import os from pydantic_settings import BaseSettings from functools import lru_cache class Settings(BaseSettings): """应用配置""" # 应用配置 APP_NAME: str = "小虾 SaaS" APP_VERSION: str = "1.0.0" BASE_URL: str = "http://localhost:3000" # 数据库配置 DATABASE_URL: str = "postgresql://xiaoxia:password@localhost:5432/xiaoxia_saas" USE_IN_MEMORY_DB: bool = False # True = 使用内存数据库,False = 使用 PostgreSQL # Redis 配置 REDIS_URL: str = "redis://localhost:6379/0" # JWT 配置 JWT_SECRET_KEY: str = "your-secret-key-change-in-production" JWT_ALGORITHM: str = "HS256" JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 JWT_REFRESH_TOKEN_EXPIRE_DAYS: int = 30 # 邮件配置 SMTP_HOST: str = "smtp.gmail.com" SMTP_PORT: int = 587 SMTP_USER: str = "" SMTP_PASSWORD: str = "" SMTP_FROM_EMAIL: str = "" SMTP_FROM_NAME: str = "小虾 SaaS" # 环境 ENVIRONMENT: str = "development" # development, staging, production DEBUG: bool = True # CORS CORS_ORIGINS: list = ["http://localhost:3000", "http://localhost:5173"] class Config: env_file = ".env" case_sensitive = True @lru_cache() def get_settings() -> Settings: """获取配置(单例)""" return Settings() # 全局配置实例 settings = get_settings()