You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.8 KiB

{% extends "base.html" %}
{% block title %}用户管理 - 邮件系统{% endblock %}
{% block content %}
<div class="main-layout">
<div class="sidebar">
<a href="{{ url_for('admin_dashboard') }}">📊 仪表盘</a>
<a href="{{ url_for('admin_users') }}" class="active">👥 用户管理</a>
<a href="{{ url_for('admin_services') }}">⚙️ 服务管理</a>
<a href="{{ url_for('admin_settings') }}">🔧 系统设置</a>
<a href="{{ url_for('admin_filters') }}">🛡️ 过滤规则</a>
<a href="{{ url_for('admin_logs') }}">📋 日志管理</a>
<a href="{{ url_for('admin_broadcast') }}">📢 群发邮件</a>
<hr style="margin: 1rem 0;">
<a href="{{ url_for('inbox') }}">← 返回邮箱</a>
</div>
<div class="main-content">
<div class="card">
<h2 style="margin-bottom: 1rem;">添加用户</h2>
<form method="POST" action="{{ url_for('admin_add_user') }}"
style="display: flex; gap: 1rem; flex-wrap: wrap; align-items: end;">
<div class="form-group" style="margin: 0;">
<label>用户名</label>
<input type="text" name="username" required>
</div>
<div class="form-group" style="margin: 0;">
<label>邮箱</label>
<input type="email" name="email" required>
</div>
<div class="form-group" style="margin: 0;">
<label>密码</label>
<input type="password" name="password" required>
</div>
<div class="form-group" style="margin: 0;">
<label><input type="checkbox" name="is_admin"> 管理员</label>
</div>
<button type="submit" class="btn btn-primary">添加</button>
</form>
</div>
<div class="card">
<h2 style="margin-bottom: 1rem;">用户列表</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>用户名</th>
<th>邮箱</th>
<th>角色</th>
<th>状态</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td><span class="badge {% if user.is_admin %}badge-warning{% else %}badge-success{% endif %}">{{
'管理员' if user.is_admin else '普通用户' }}</span></td>
<td><span class="badge {% if user.is_active %}badge-success{% else %}badge-danger{% endif %}">{{
'启用' if user.is_active else '禁用' }}</span></td>
<td>{{ user.created_at.strftime('%Y-%m-%d') }}</td>
<td>
{% if user.id != current_user.id %}
<a href="{{ url_for('admin_toggle_user', id=user.id) }}" class="btn btn-secondary">{{ '禁用'
if user.is_active else '启用' }}</a>
<a href="{{ url_for('admin_delete_user', id=user.id) }}" class="btn btn-danger"
onclick="return confirm('确定删除?')">删除</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}