功能: - 激活码管理 (Pro/Auto 两种类型) - 账号池管理 - 设备绑定记录 - 使用日志 - 搜索/筛选功能 - 禁用/启用功能 (支持退款参考) - 全局设置 (换号间隔、额度消耗等) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import os
|
|
from pydantic_settings import BaseSettings
|
|
from typing import Optional
|
|
|
|
class Settings(BaseSettings):
|
|
# 数据库配置
|
|
USE_SQLITE: bool = True # 设为 False 使用 MySQL
|
|
DB_HOST: str = "localhost"
|
|
DB_PORT: int = 3306
|
|
DB_USER: str = "root"
|
|
DB_PASSWORD: str = ""
|
|
DB_NAME: str = "cursorpro"
|
|
|
|
# JWT配置
|
|
SECRET_KEY: str = "your-secret-key-change-in-production"
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7天
|
|
|
|
# 管理员账号
|
|
ADMIN_USERNAME: str = "admin"
|
|
ADMIN_PASSWORD: str = "admin123"
|
|
|
|
@property
|
|
def DATABASE_URL(self) -> str:
|
|
if self.USE_SQLITE:
|
|
# SQLite 用于本地测试
|
|
db_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "cursorpro.db")
|
|
return f"sqlite:///{db_path}"
|
|
return f"mysql+pymysql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}?charset=utf8mb4"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
extra = "allow"
|
|
|
|
settings = Settings()
|