| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- {% extends "base.html" %}
- {% block title %}逐鹿导航 - 管理后台{% endblock %}
- {% block content %}
- <div class="container-fluid px-4">
- <div class="d-flex justify-content-between align-items-center mb-4">
- <h2 class="mb-0">
- <i class="bi bi-speedometer2 me-2"></i>管理后台
- </h2>
- <div>
- <a href="{{ url_for('dashboard') }}" class="btn btn-outline-secondary me-2">
- <i class="bi bi-arrow-left-circle"></i> 返回我的导航
- </a>
- <a href="{{ url_for('index') }}" class="btn btn-primary">
- <i class="bi bi-house-door"></i> 查看首页
- </a>
- </div>
- </div>
- <!-- 用户管理部分 -->
- <div class="card shadow-sm mb-4">
- <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
- <h5 class="mb-0">
- <i class="bi bi-people-fill me-2"></i>用户管理
- </h5>
- <div>
- <a href="{{ url_for('add_user') }}" class="btn btn-light btn-sm">
- <i class="bi bi-plus-lg me-1"></i>添加用户
- </a>
- <span class="badge bg-light text-dark ms-2">{{ users|length }} 用户</span>
- </div>
- </div>
- <div class="card-body">
- {% if users %}
- <div class="table-responsive">
- <table class="table table-hover">
- <thead class="table-light">
- <tr>
- <th>ID</th>
- <th>用户名</th>
- <th>邮箱</th>
- <th>注册时间</th>
- <th>状态</th>
- <th class="text-end">操作</th>
- </tr>
- </thead>
- <tbody>
- {% for user in users %}
- <tr class="{% if user.id == current_user.id %}table-active{% endif %}">
- <td>{{ user.id }}</td>
- <td>
- {{ user.username }}
- {% if user.id == current_user.id %}
- <span class="badge bg-info ms-2">当前用户</span>
- {% endif %}
- </td>
- <td>{{ user.email }}</td>
- <td>{{ user.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
- <td>
- {% if user.is_admin %}
- <span class="badge bg-danger">管理员</span>
- {% else %}
- <span class="badge bg-secondary">普通用户</span>
- {% endif %}
- </td>
- <td class="text-end">
- <div class="btn-group btn-group-sm" role="group">
- <a href="{{ url_for('edit_user', user_id=user.id) }}"
- class="btn btn-outline-primary">
- <i class="bi bi-pencil-square"></i> 编辑
- </a>
- {% if user.id != current_user.id %}
- <form method="POST" action="{{ url_for('delete_user', user_id=user.id) }}"
- class="d-inline"
- onsubmit="return confirm('确定要删除用户 {{ user.username }} 吗?');">
- <button type="submit" class="btn btn-outline-danger">
- <i class="bi bi-trash"></i> 删除
- </button>
- </form>
- <form method="POST" action="{{ url_for('toggle_admin', user_id=user.id) }}"
- class="d-inline"
- onsubmit="return confirm('确定要将用户 {{ user.username }} {{ "设为管理员" if not user.is_admin else "降级为普通用户" }}吗?');">
- <button type="submit" class="btn {{ 'btn-warning' if user.is_admin else 'btn-success' }}">
- <i class="bi {{ 'bi-person-dash' if user.is_admin else 'bi-person-plus' }}"></i>
- {{ '降级' if user.is_admin else '升级' }}
- </button>
- </form>
- {% endif %}
- </div>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% else %}
- <div class="text-center py-4">
- <i class="bi bi-people display-5 text-muted mb-3"></i>
- <p class="text-muted">暂无用户数据</p>
- <a href="{{ url_for('add_user') }}" class="btn btn-primary">
- <i class="bi bi-plus-lg me-1"></i>添加用户
- </a>
- </div>
- {% endif %}
- </div>
- </div>
- <!-- 公共分类管理部分 -->
- <div class="card shadow-sm mb-4">
- <div class="card-header bg-success text-white d-flex justify-content-between align-items-center">
- <h5 class="mb-0">
- <i class="bi bi-tags-fill me-2"></i>公共分类管理
- </h5>
- <span class="badge bg-light text-dark">{{ public_categories|length }} 分类</span>
- </div>
- <div class="card-body">
- {% if public_categories %}
- <div class="table-responsive">
- <table class="table table-hover">
- <thead class="table-light">
- <tr>
- <th>ID</th>
- <th>分类名称</th>
- <th>创建时间</th>
- <th class="text-end">操作</th>
- </tr>
- </thead>
- <tbody>
- {% for category in public_categories %}
- <tr>
- <td>{{ category.id }}</td>
- <td>
- <span class="badge bg-success bg-opacity-10 text-success">
- {{ category.name }}
- </span>
- </td>
- <td>{{ category.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
- <td class="text-end">
- <div class="btn-group btn-group-sm" role="group">
- <a href="{{ url_for('edit_public_category', category_id=category.id) }}"
- class="btn btn-outline-primary">
- <i class="bi bi-pencil-square"></i> 编辑
- </a>
- <form method="POST" action="{{ url_for('delete_public_category', category_id=category.id) }}"
- class="d-inline"
- onsubmit="return confirm('确定要删除分类 {{ category.name }} 吗?');">
- <button type="submit" class="btn btn-outline-danger">
- <i class="bi bi-trash"></i> 删除
- </button>
- </form>
- </div>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% else %}
- <div class="text-center py-4">
- <i class="bi bi-tag display-5 text-muted mb-3"></i>
- <p class="text-muted">暂无公共分类</p>
- </div>
- {% endif %}
- </div>
- </div>
- <!-- 公共站点管理部分 -->
- <div class="card shadow-sm">
- <div class="card-header bg-info text-white d-flex justify-content-between align-items-center">
- <h5 class="mb-0">
- <i class="bi bi-bookmark-star-fill me-2"></i>公共站点管理
- </h5>
- <span class="badge bg-light text-dark">{{ public_sites|length }} 站点</span>
- </div>
- <div class="card-body">
- {% if public_sites %}
- <div class="table-responsive">
- <table class="table table-hover">
- <thead class="table-light">
- <tr>
- <th>ID</th>
- <th>站点名称</th>
- <th>URL</th>
- <th>分类</th>
- <th>创建时间</th>
- <th class="text-end">操作</th>
- </tr>
- </thead>
- <tbody>
- {% for site in public_sites %}
- <tr>
- <td>{{ site.id }}</td>
- <td>{{ site.name }}</td>
- <td>
- <a href="{{ site.url }}" target="_blank" class="text-decoration-none">
- <i class="bi bi-box-arrow-up-right"></i> {{ site.url|truncate(30) }}
- </a>
- </td>
- <td>
- <span class="badge bg-success bg-opacity-10 text-success">
- {{ site.category.name if site.category else '未分类' }}
- </span>
- </td>
- <td>{{ site.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
- <td class="text-end">
- <div class="btn-group btn-group-sm" role="group">
- <a href="{{ url_for('edit_public_site', site_id=site.id) }}"
- class="btn btn-outline-primary">
- <i class="bi bi-pencil-square"></i> 编辑
- </a>
- <form method="POST" action="{{ url_for('delete_public_site', site_id=site.id) }}"
- class="d-inline"
- onsubmit="return confirm('确定要删除站点 {{ site.name }} 吗?');">
- <button type="submit" class="btn btn-outline-danger">
- <i class="bi bi-trash"></i> 删除
- </button>
- </form>
- </div>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% else %}
- <div class="text-center py-4">
- <i class="bi bi-bookmark display-5 text-muted mb-3"></i>
- <p class="text-muted">暂无公共站点</p>
- </div>
- {% endif %}
- </div>
- </div>
- </div>
- {% endblock %}
- {% block styles %}
- <style>
- .btn-group-sm .btn {
- padding: 0.25rem 0.5rem;
- font-size: 0.875rem;
- border-radius: 0.25rem;
- }
- .btn-group .btn {
- margin-right: 0.25rem;
- }
- .btn-group .btn:last-child {
- margin-right: 0;
- }
- .table-active {
- background-color: rgba(13, 110, 253, 0.1);
- }
- .badge.bg-success.bg-opacity-10 {
- background-color: rgba(25, 135, 84, 0.1);
- }
- .text-truncate {
- max-width: 200px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- display: inline-block;
- }
- @media (max-width: 768px) {
- .btn-group {
- flex-wrap: wrap;
- gap: 0.25rem;
- }
- .btn-group .btn {
- margin-right: 0;
- }
- }
- </style>
- {% endblock %}
|