feat: 登录验证 + 邀请码注册 + 用量监控后台

- 新增用户认证系统(登录/登出/邀请码注册)
- 新增管理后台(邀请码管理/用户管理/使用记录/用量统计)
- 合成接口加登录验证,每次调用记录用户和稿件内容
- SQLite存储用户数据和使用日志
- 默认admin账号: simonkoson

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
lanhao
2026-07-02 18:51:23 +08:00
parent 3b6019d0f2
commit 223761e717
10 changed files with 1304 additions and 27 deletions
+28 -2
View File
@@ -1,14 +1,40 @@
from flask import Flask, jsonify
from flask_cors import CORS
from dotenv import load_dotenv
import os
load_dotenv()
def create_app():
app = Flask(__name__)
CORS(app, resources={r"/api/*": {"origins": "*"}})
# Session 配置
app.secret_key = os.getenv('FLASK_SECRET_KEY', 'military-tech-voice-secret-2026')
app.config['SESSION_COOKIE_HTTPONLY'] = True
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
app.config['PERMANENT_SESSION_LIFETIME'] = 86400 * 7 # 7天免重登
CORS(app, resources={r"/api/*": {"origins": "*"}}, supports_credentials=True)
# 初始化数据库
from app.db import init_db
init_db()
# 注册蓝图
from app.routes.tts_synthesize import bp as synthesize_bp
from app.routes.auth import bp as auth_bp
from app.routes.admin import bp as admin_bp
app.register_blueprint(synthesize_bp)
app.register_blueprint(auth_bp)
app.register_blueprint(admin_bp)
@app.route('/api/health')
def health(): return jsonify({'status': 'ok', 'service': '军事科技AI配音系统'})
def health():
return jsonify({'status': 'ok', 'service': '军事科技AI配音系统'})
return app
if __name__ == '__main__':
create_app().run(host='0.0.0.0', port=5000, debug=True)