更新新增三个模块

This commit is contained in:
super
2026-03-22 11:20:09 +08:00
parent c80e1889ef
commit 497d65d41d
96 changed files with 5393 additions and 588 deletions

View File

@@ -0,0 +1,40 @@
"""
版本公开 API 蓝图:当前版本、最新版本下载链接
"""
import os
from flask import Blueprint, jsonify
from utils.db import get_db
version_bp = Blueprint('version', __name__, url_prefix='/api')
@version_bp.route('/version')
def api_version():
"""检测更新:返回当前版本及可选的最新版本信息"""
return jsonify({
'version': os.environ.get('APP_VERSION', '1.0.0'),
'desc': '',
'url': os.environ.get('APP_UPDATE_URL', ''),
})
@version_bp.route('/version/latest')
def api_version_latest():
"""GET 获取最新版本的下载链接(按创建时间取最新一条)"""
try:
conn = get_db()
with conn.cursor() as cur:
cur.execute(
"SELECT version, file_url FROM web_config ORDER BY created_at DESC LIMIT 1"
)
row = cur.fetchone()
conn.close()
if not row:
return jsonify({'version': None, 'file_url': None})
return jsonify({
'version': row['version'] or '',
'file_url': row['file_url'] or '',
})
except Exception as e:
return jsonify({'error': str(e)}), 500