- 将 routes/admin.py (672行) 拆分为 routes/admin/ 包 - 按功能模块拆分:auth, dashboard, articles, categories, tags, settings, stats, upload, authors - 端口从 16012 改为 16013 - 初始化数据库和管理员账户
21 lines
620 B
Python
21 lines
620 B
Python
"""后台管理路由模块"""
|
|
from flask import Blueprint, session, flash, redirect, url_for
|
|
from functools import wraps
|
|
|
|
admin_bp = Blueprint('admin', __name__)
|
|
|
|
|
|
def login_required(f):
|
|
"""登录验证装饰器"""
|
|
@wraps(f)
|
|
def decorated_function(*args, **kwargs):
|
|
if 'admin_id' not in session:
|
|
flash('请先登录', 'warning')
|
|
return redirect(url_for('admin.login'))
|
|
return f(*args, **kwargs)
|
|
return decorated_function
|
|
|
|
|
|
# 导入子模块以注册路由
|
|
from app.routes.admin import auth, dashboard, articles, categories, tags, settings, stats, upload, authors
|