feat(app): migrate /app accounts to Vue SPA (stage 3)

This commit is contained in:
2025-12-13 23:56:47 +08:00
parent 324e0d614a
commit 9798ed52c3
26 changed files with 1098 additions and 69 deletions

40
app.py
View File

@@ -1202,7 +1202,14 @@ def register_page():
@login_required
def app_page():
"""主应用页面"""
return render_template('index.html')
return render_app_spa_or_legacy('index.html')
@app.route('/app/<path:subpath>')
@login_required
def app_page_subpath(subpath):
"""SPA 子路由刷新支持History 模式)"""
return render_app_spa_or_legacy('index.html')
@app.route('/yuyx')
@@ -2608,6 +2615,33 @@ def delete_account(account_id):
return jsonify({"success": True})
@app.route('/api/accounts/clear', methods=['POST'])
@login_required
def clear_accounts():
"""清空当前用户的所有账号"""
user_id = current_user.id
accounts = user_accounts.get(user_id, {})
if any(acc.is_running for acc in accounts.values()):
return jsonify({"error": "有任务正在运行,请先停止后再清空"}), 400
account_ids = list(accounts.keys())
deleted = database.delete_user_accounts(user_id)
# 清理内存缓存
if user_id in user_accounts:
user_accounts[user_id] = {}
# 清理任务状态缓存
for account_id in account_ids:
safe_remove_task_status(account_id)
safe_remove_task(account_id)
log_to_client(f"清空账号: {deleted}", user_id)
return jsonify({"success": True, "deleted": deleted})
@app.route('/api/accounts/<account_id>/remark', methods=['PUT'])
@login_required
def update_remark(account_id):
@@ -3380,6 +3414,10 @@ def take_screenshot_for_account(user_id, account_id, browse_type="应读", sourc
)
if not submitted:
screenshot_callback(None, "截图队列已满,请稍后重试")
@app.route('/api/accounts/<account_id>/screenshot', methods=['POST'])
@login_required
def manual_screenshot(account_id):
"""手动为指定账号截图"""
user_id = current_user.id