"""仪表盘路由""" from flask import render_template from app.routes.admin import admin_bp, login_required from app.services import ArticleService, CategoryService, TagService @admin_bp.route('/') @admin_bp.route('/dashboard') @login_required def dashboard(): """仪表盘""" articles = ArticleService.get_all_list(per_page=5) categories = CategoryService.get_all() tags = TagService.get_all() stats = { 'total_articles': len(articles.items), 'published_articles': sum(1 for a in articles.items if a.is_published), 'total_categories': len(categories), 'total_tags': len(tags), 'total_views': sum(a.view_count for a in articles.items) } return render_template('admin/dashboard.html', stats=stats, recent_articles=articles)