Files
tech-blog/app/routes/admin/dashboard.py
hz4th_coder 503a9780b2 refactor: 拆分admin路由为模块化结构,端口改为16013
- 将 routes/admin.py (672行) 拆分为 routes/admin/ 包
- 按功能模块拆分:auth, dashboard, articles, categories, tags, settings, stats, upload, authors
- 端口从 16012 改为 16013
- 初始化数据库和管理员账户
2026-06-25 11:21:36 +08:00

25 lines
805 B
Python

"""仪表盘路由"""
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)