前后端数据流对齐:

后端改动:

GET /api/v1/accounts 现在返回分页格式 {items, total, page, size, total_pages, status_counts},默认每页 12 个
批量操作用 size=500 一次拉全部
前端改动:

base.html — 加了移动端汉堡菜单、全局响应式样式、pagination disabled 状态
dashboard.html — 账号卡片分页,统计数据从 API 的 status_counts 取,移动端单列布局
account_detail.html — 签到记录改成上下两行布局(topic+状态 / 消息+时间),分页用统一的上一页/下一页样式,移动端适配
分页逻辑统一:前后端都用 page/total_pages 字段,pagination 组件显示当前页 ±2 页码。
This commit is contained in:
2026-03-18 09:45:55 +08:00
parent 642cf76b61
commit 8f4e0a2411
7 changed files with 309 additions and 416 deletions

View File

@@ -213,18 +213,32 @@ def logout():
@app.route('/dashboard')
@login_required
def dashboard():
page = request.args.get('page', 1, type=int)
try:
response = api_request(
'GET',
f'{API_BASE_URL}/api/v1/accounts',
params={'page': page, 'size': 12},
)
data = response.json()
accounts = data.get('data', []) if data.get('success') else []
if data.get('success'):
payload = data.get('data', {})
# 兼容旧版 API返回列表和新版返回分页对象
if isinstance(payload, list):
accounts = payload
pagination = {'items': payload, 'total': len(payload), 'page': 1, 'size': len(payload), 'total_pages': 1, 'status_counts': {}}
else:
accounts = payload.get('items', [])
pagination = payload
else:
accounts = []
pagination = {'items': [], 'total': 0, 'page': 1, 'size': 12, 'total_pages': 0, 'status_counts': {}}
except requests.RequestException:
accounts = []
pagination = {'items': [], 'total': 0, 'page': 1, 'size': 12, 'total_pages': 0, 'status_counts': {}}
flash('加载账号列表失败', 'warning')
return render_template('dashboard.html', accounts=accounts, user=session.get('user'))
return render_template('dashboard.html', accounts=accounts, pagination=pagination, user=session.get('user'))
@app.route('/accounts/new')
@login_required
@@ -841,9 +855,10 @@ def delete_task(task_id):
def batch_verify():
"""批量验证所有账号的 Cookie 有效性"""
try:
response = api_request('GET', f'{API_BASE_URL}/api/v1/accounts')
response = api_request('GET', f'{API_BASE_URL}/api/v1/accounts', params={'page': 1, 'size': 500})
data = response.json()
accounts = data.get('data', []) if data.get('success') else []
payload = data.get('data', {}) if data.get('success') else {}
accounts = payload.get('items', []) if isinstance(payload, dict) else payload
valid = invalid = errors = 0
for account in accounts:
@@ -871,9 +886,10 @@ def batch_verify():
def batch_signin():
"""批量签到所有正常状态的账号"""
try:
response = api_request('GET', f'{API_BASE_URL}/api/v1/accounts')
response = api_request('GET', f'{API_BASE_URL}/api/v1/accounts', params={'page': 1, 'size': 500})
data = response.json()
accounts = data.get('data', []) if data.get('success') else []
payload = data.get('data', {}) if data.get('success') else {}
accounts = payload.get('items', []) if isinstance(payload, dict) else payload
total_signed = total_already = total_failed = 0
processed = 0

View File

@@ -4,44 +4,41 @@
{% block extra_css %}
<style>
.detail-header {
display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;
}
.detail-header h1 { font-size: 24px; font-weight: 700; color: #1e293b; }
.info-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px;
}
@media (max-width: 768px) { .info-grid { grid-template-columns: 1fr; } }
.info-table td { padding: 12px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.detail-header h1 { font-size: 20px; font-weight: 700; color: #1e293b; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.info-table td { padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.info-table td:first-child { font-weight: 600; color: #64748b; width: 30%; }
.action-btn {
width: 100%; padding: 12px; border-radius: 14px; border: none;
font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
width: 100%; padding: 10px; border-radius: 12px; border: none;
font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
text-align: center; text-decoration: none; display: block;
}
.action-btn-primary {
background: linear-gradient(135deg, #6366f1, #818cf8); color: white;
box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.action-btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.35); transform: translateY(-1px); }
.action-btn-primary { background: linear-gradient(135deg, #6366f1, #818cf8); color: white; }
.action-btn-primary:hover { transform: translateY(-1px); }
.action-btn-secondary { background: #f1f5f9; color: #475569; }
.action-btn-secondary:hover { background: #e2e8f0; }
.task-row {
display: flex; align-items: center; justify-content: space-between;
padding: 14px 0; border-bottom: 1px solid #f1f5f9;
}
.task-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; gap: 8px; }
.task-row:last-child { border-bottom: none; }
.task-cron {
font-family: 'SF Mono', Monaco, monospace; background: #eef2ff; color: #6366f1;
padding: 4px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
.task-cron { font-family: 'SF Mono', Monaco, monospace; background: #eef2ff; color: #6366f1; padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.task-actions { display: flex; gap: 6px; }
.task-actions .btn { padding: 5px 12px; font-size: 11px; border-radius: 8px; }
/* 签到记录 - 移动端友好 */
.log-item { padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.log-item:last-child { border-bottom: none; }
.log-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.log-topic { font-weight: 500; color: #1e293b; font-size: 14px; }
.log-bottom { display: flex; justify-content: space-between; align-items: center; }
.log-msg { font-size: 12px; color: #64748b; flex: 1; margin-right: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-date { font-size: 11px; color: #94a3b8; white-space: nowrap; }
@media (max-width: 768px) {
.info-grid { grid-template-columns: 1fr; }
.detail-header { flex-direction: column; align-items: flex-start; }
.task-row { flex-direction: column; align-items: flex-start; }
.task-actions { width: 100%; justify-content: flex-end; }
}
.task-actions { display: flex; gap: 8px; }
.task-actions .btn { padding: 6px 14px; font-size: 12px; border-radius: 10px; }
.log-row {
display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px;
align-items: center; padding: 12px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px;
}
.log-row:last-child { border-bottom: none; }
</style>
{% endblock %}
@@ -50,9 +47,9 @@
<div class="detail-header">
<div>
<h1>{{ account.remark or account.weibo_user_id }}</h1>
<div style="color:#94a3b8; font-size:14px; margin-top:4px;">UID: {{ account.weibo_user_id }}</div>
<div style="color:#94a3b8; font-size:13px; margin-top:2px;">UID: {{ account.weibo_user_id }}</div>
</div>
<div style="display:flex; gap:10px;">
<div style="display:flex; gap:8px;">
<a href="{{ url_for('edit_account', account_id=account.id) }}" class="btn btn-secondary">✏️ 编辑</a>
<form method="POST" action="{{ url_for('delete_account', account_id=account.id) }}" style="display:inline;" onsubmit="return confirm('确定要删除此账号吗?');">
<button type="submit" class="btn btn-danger">删除</button>
@@ -81,7 +78,7 @@
</div>
<div class="card">
<div class="card-header">⚡ 快捷操作</div>
<div style="display:flex; flex-direction:column; gap:10px;">
<div style="display:flex; flex-direction:column; gap:8px;">
<form method="POST" action="{{ url_for('verify_account', account_id=account.id) }}">
<button type="submit" class="action-btn action-btn-secondary">🔍 验证 Cookie</button>
</form>
@@ -99,7 +96,7 @@
{% if tasks %}
{% for task in tasks %}
<div class="task-row">
<div style="display:flex; align-items:center; gap:12px;">
<div style="display:flex; align-items:center; gap:10px;">
<span class="task-cron">{{ task.cron_expression }}</span>
{% if task.is_enabled %}<span class="badge badge-success">已启用</span>
{% else %}<span class="badge badge-warning">已禁用</span>{% endif %}
@@ -110,7 +107,7 @@
<input type="hidden" name="is_enabled" value="{{ task.is_enabled|lower }}">
<button type="submit" class="btn btn-secondary">{% if task.is_enabled %}禁用{% else %}启用{% endif %}</button>
</form>
<form method="POST" action="{{ url_for('delete_task', task_id=task.id) }}" style="display:inline;" onsubmit="return confirm('确定删除此任务吗');">
<form method="POST" action="{{ url_for('delete_task', task_id=task.id) }}" style="display:inline;" onsubmit="return confirm('确定删除?');">
<input type="hidden" name="account_id" value="{{ account.id }}">
<button type="submit" class="btn btn-danger">删除</button>
</form>
@@ -118,53 +115,60 @@
</div>
{% endfor %}
{% else %}
<p style="color:#94a3b8; text-align:center; padding:24px; font-size:14px;">暂无定时任务</p>
<p style="color:#94a3b8; text-align:center; padding:20px; font-size:13px;">暂无定时任务</p>
{% endif %}
</div>
<div class="card">
<div class="card-header">📝 签到记录</div>
{% if logs['items'] %}
<div class="card-header">📝 签到记录 {% if logs.get('total', 0) > 0 %}(共 {{ logs.total }} 条){% endif %}</div>
{% if logs.get('items') %}
{% for log in logs['items'] %}
<div class="log-row">
<div style="font-weight:500; color:#1e293b;">{{ log.topic_title or '-' }}</div>
<div>
<div class="log-item">
<div class="log-top">
<span class="log-topic">{{ log.topic_title or '-' }}</span>
{% if log.status == 'success' %}<span class="badge badge-success">签到成功</span>
{% elif log.status == 'failed_already_signed' %}<span class="badge badge-info">今日已签</span>
{% elif log.status == 'failed_network' %}<span class="badge badge-warning">网络错误</span>
{% elif log.status == 'failed_banned' %}<span class="badge badge-danger">已封禁</span>
{% else %}<span class="badge badge-info">{{ log.status }}</span>
{% endif %}
</div>
<div style="font-size:13px; color:#64748b;">
{% if log.reward_info %}
{% if log.reward_info is mapping %}
{{ log.reward_info.get('message', '-') }}
{% else %}
{{ log.reward_info }}
{% endif %}
{% else %}-{% endif %}
<div class="log-bottom">
<span class="log-msg">
{% if log.reward_info %}
{% if log.reward_info is mapping %}{{ log.reward_info.get('message', '-') }}
{% else %}{{ log.reward_info }}{% endif %}
{% else %}-{% endif %}
</span>
<span class="log-date">{{ log.signed_at[:16] | replace('T', ' ') }}</span>
</div>
<div style="color:#94a3b8; font-size:13px;">{{ log.signed_at[:10] }}</div>
</div>
{% endfor %}
{% if logs['total'] > logs['size'] %}
{% set p = logs.get('page', 1) %}
{% set tp = logs.get('total_pages', 1) %}
{% if tp > 1 %}
<div class="pagination">
{% if logs['page'] > 1 %}
<a href="?page=1"></a>
<a href="?page={{ logs['page'] - 1 }}">上一页</a>
{% if p > 1 %}
<a href="?page={{ p - 1 }}"> 上一</a>
{% else %}
<span class="disabled"> 上一页</span>
{% endif %}
{% for p in range(max(1, logs['page'] - 2), min(logs['total'] // logs['size'] + 2, logs['page'] + 3)) %}
{% if p == logs['page'] %}<span class="active">{{ p }}</span>
{% else %}<a href="?page={{ p }}">{{ p }}</a>{% endif %}
{% for i in range(max(1, p - 2), min(tp, p + 2) + 1) %}
{% if i == p %}<span class="active">{{ i }}</span>
{% else %}<a href="?page={{ i }}">{{ i }}</a>{% endif %}
{% endfor %}
{% if logs['page'] < logs['total'] // logs['size'] + 1 %}
<a href="?page={{ logs['page'] + 1 }}">下一页</a>
<a href="?page={{ logs['total'] // logs['size'] + 1 }}">末页</a>
{% if p < tp %}
<a href="?page={{ p + 1 }}">下一页 </a>
{% else %}
<span class="disabled">下一页 </span>
{% endif %}
</div>
{% endif %}
{% else %}
<p style="color:#94a3b8; text-align:center; padding:24px; font-size:14px;">暂无签到记录</p>
<p style="color:#94a3b8; text-align:center; padding:20px; font-size:13px;">暂无签到记录</p>
{% endif %}
</div>
</div>

View File

@@ -2,216 +2,138 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>{% block title %}微博超话签到{% endblock %}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
background: linear-gradient(135deg, #f0f2ff 0%, #faf5ff 50%, #fff0f6 100%);
color: #1a1a2e;
min-height: 100vh;
color: #1a1a2e; min-height: 100vh;
}
/* ---- Navbar ---- */
.navbar {
background: rgba(255,255,255,0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(99,102,241,0.08);
padding: 0 24px;
position: sticky;
top: 0;
z-index: 100;
padding: 0 16px; position: sticky; top: 0; z-index: 100;
}
.navbar-content {
max-width: 1200px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
height: 64px;
max-width: 1200px; margin: 0 auto;
display: flex; justify-content: space-between; align-items: center; height: 52px;
}
.navbar-brand {
font-size: 22px;
font-weight: 700;
font-size: 18px; font-weight: 700;
background: linear-gradient(135deg, #6366f1, #a855f7);
-webkit-background-clip: text;
-webkit-background-clip: text; background-clip: text;
-webkit-text-fill-color: transparent;
text-decoration: none;
}
.navbar-menu {
display: flex;
gap: 28px;
align-items: center;
text-decoration: none; white-space: nowrap;
}
.navbar-menu { display: flex; gap: 20px; align-items: center; }
.navbar-menu > a {
color: #64748b;
text-decoration: none;
font-size: 15px;
font-weight: 500;
transition: color 0.2s;
padding: 6px 0;
color: #64748b; text-decoration: none; font-size: 14px;
font-weight: 500; transition: color 0.2s;
}
.navbar-menu > a:hover { color: #6366f1; }
.navbar-user {
display: flex;
gap: 14px;
align-items: center;
}
.navbar-user span {
color: #475569;
font-size: 14px;
font-weight: 500;
}
.navbar-user { display: flex; gap: 10px; align-items: center; }
.navbar-user span { color: #475569; font-size: 13px; font-weight: 500; }
.btn-logout {
background: linear-gradient(135deg, #f43f5e, #e11d48);
color: white;
padding: 7px 18px;
border: none;
border-radius: 20px;
cursor: pointer;
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: opacity 0.2s;
background: linear-gradient(135deg, #f43f5e, #e11d48); color: white;
padding: 5px 14px; border: none; border-radius: 20px; cursor: pointer;
text-decoration: none; font-size: 12px; font-weight: 500;
}
.btn-logout:hover { opacity: 0.85; }
.container {
max-width: 1200px;
margin: 28px auto;
padding: 0 20px;
.navbar-toggle {
display: none; background: none; border: none;
font-size: 22px; cursor: pointer; color: #475569; padding: 4px;
}
.alert {
padding: 14px 20px;
margin-bottom: 20px;
border-radius: 16px;
font-size: 14px;
font-weight: 500;
}
/* ---- Layout ---- */
.container { max-width: 1200px; margin: 16px auto; padding: 0 16px; }
/* ---- Alerts ---- */
.alert { padding: 10px 14px; margin-bottom: 14px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 600; color: #334155; font-size: 14px; }
/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-weight: 600; color: #334155; font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
width: 100%;
padding: 12px 16px;
border: 1.5px solid #e2e8f0;
border-radius: 14px;
font-size: 14px;
font-family: inherit;
background: #fff;
transition: border-color 0.2s, box-shadow 0.2s;
width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0;
border-radius: 12px; font-size: 14px; font-family: inherit; background: #fff;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
textarea:focus, select:focus {
outline: none;
border-color: #818cf8;
box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
input:focus, textarea:focus, select:focus {
outline: none; border-color: #818cf8; box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
textarea { resize: vertical; min-height: 100px; }
textarea { resize: vertical; min-height: 80px; }
/* ---- Buttons ---- */
.btn {
padding: 10px 22px;
border: none;
border-radius: 14px;
cursor: pointer;
font-size: 14px;
font-weight: 600;
transition: all 0.2s;
text-decoration: none;
display: inline-block;
}
.btn-primary {
background: linear-gradient(135deg, #6366f1, #818cf8);
color: white;
box-shadow: 0 2px 8px rgba(99,102,241,0.25);
padding: 8px 16px; border: none; border-radius: 12px; cursor: pointer;
font-size: 13px; font-weight: 600; transition: all 0.2s;
text-decoration: none; display: inline-block; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #6366f1, #818cf8); color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.25); }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.35); transform: translateY(-1px); }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
background: linear-gradient(135deg, #f43f5e, #e11d48);
color: white;
box-shadow: 0 2px 8px rgba(244,63,94,0.25);
}
.btn-danger:hover { box-shadow: 0 4px 16px rgba(244,63,94,0.35); }
.btn-success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.btn-success:hover { box-shadow: 0 4px 16px rgba(16,185,129,0.35); }
.btn-group { display: flex; gap: 10px; margin-top: 20px; }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: white; }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.btn-group { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
/* ---- Cards ---- */
.card {
background: rgba(255,255,255,0.9);
backdrop-filter: blur(8px);
border-radius: 20px;
box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
padding: 24px;
margin-bottom: 20px;
border: 1px solid rgba(255,255,255,0.6);
background: rgba(255,255,255,0.9); backdrop-filter: blur(8px);
border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
padding: 16px; margin-bottom: 14px; border: 1px solid rgba(255,255,255,0.6);
}
.card-header {
font-size: 17px;
font-weight: 700;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 2px solid #f1f5f9;
color: #1e293b;
font-size: 15px; font-weight: 700; margin-bottom: 12px;
padding-bottom: 10px; border-bottom: 2px solid #f1f5f9; color: #1e293b;
}
.badge {
display: inline-block;
padding: 4px 14px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #ecfdf5; color: #059669; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-danger { background: #fef2f2; color: #dc2626; }
.badge-info { background: #eff6ff; color: #2563eb; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th {
background: #f8fafc;
padding: 12px 16px;
text-align: left;
font-weight: 600;
font-size: 13px;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.5px;
border-bottom: 2px solid #e2e8f0;
}
td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
tr:hover { background: #f8fafc; }
/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; padding: 8px 10px; text-align: left; font-weight: 600; font-size: 12px; color: #64748b; border-bottom: 2px solid #e2e8f0; }
td { padding: 10px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
/* ---- Pagination ---- */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
padding: 8px 14px;
border: 1.5px solid #e2e8f0;
border-radius: 12px;
text-decoration: none;
color: #6366f1;
font-size: 14px;
font-weight: 500;
padding: 6px 12px; border: 1.5px solid #e2e8f0; border-radius: 10px;
text-decoration: none; color: #6366f1; font-size: 13px; font-weight: 500;
}
.pagination a:hover { background: #f1f5f9; }
.pagination .active { background: #6366f1; color: white; border-color: #6366f1; }
.pagination .disabled { color: #cbd5e1; pointer-events: none; }
/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
.navbar-menu { display: none; }
.navbar-toggle { display: block; }
.navbar-menu {
display: none; flex-direction: column; gap: 0;
position: absolute; top: 52px; left: 0; right: 0;
background: rgba(255,255,255,0.98); backdrop-filter: blur(12px);
border-bottom: 1px solid #e2e8f0; padding: 8px 0;
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.navbar-menu.open { display: flex; }
.navbar-menu > a { padding: 12px 20px; font-size: 15px; border-bottom: 1px solid #f1f5f9; }
.navbar-user { padding: 12px 20px; gap: 12px; }
.container { padding: 0 12px; margin: 12px auto; }
.card { padding: 14px; border-radius: 14px; }
.btn { padding: 8px 14px; font-size: 12px; }
.btn-group { flex-direction: column; }
.btn { width: 100%; text-align: center; }
.btn-group .btn { width: 100%; text-align: center; }
}
</style>
{% block extra_css %}{% endblock %}
@@ -221,6 +143,7 @@
<nav class="navbar">
<div class="navbar-content">
<a href="{{ url_for('dashboard') }}" class="navbar-brand">🔥 微博超话签到</a>
<button class="navbar-toggle" onclick="document.querySelector('.navbar-menu').classList.toggle('open')"></button>
<div class="navbar-menu">
<a href="{{ url_for('dashboard') }}">控制台</a>
{% if session.get('user', {}).get('is_admin') %}

View File

@@ -4,200 +4,113 @@
{% block extra_css %}
<style>
.dash-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 28px;
}
.dash-header h1 {
font-size: 26px;
font-weight: 700;
color: #1e293b;
}
.dash-actions { display: flex; gap: 10px; }
/* 统计卡片 */
.stats-row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 28px;
}
.dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dash-header h1 { font-size: 22px; font-weight: 700; color: #1e293b; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
background: rgba(255,255,255,0.9);
backdrop-filter: blur(8px);
border-radius: 20px;
padding: 22px 24px;
border: 1px solid rgba(255,255,255,0.6);
box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
}
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1e293b; }
.stat-card .stat-label { font-size: 13px; color: #94a3b8; font-weight: 500; margin-top: 2px; }
/* 账号卡片网格 */
.account-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 18px;
background: rgba(255,255,255,0.9); backdrop-filter: blur(8px);
border-radius: 16px; padding: 16px; border: 1px solid rgba(255,255,255,0.6);
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-card .stat-icon { font-size: 22px; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: #1e293b; }
.stat-card .stat-label { font-size: 12px; color: #94a3b8; font-weight: 500; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.account-card {
background: rgba(255,255,255,0.92);
backdrop-filter: blur(8px);
border-radius: 20px;
padding: 24px;
border: 1px solid rgba(255,255,255,0.6);
box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
cursor: pointer;
transition: all 0.25s ease;
position: relative;
overflow: hidden;
}
.account-card::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 4px;
border-radius: 20px 20px 0 0;
background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
border-radius: 16px; padding: 18px; border: 1px solid rgba(255,255,255,0.6);
box-shadow: 0 1px 3px rgba(0,0,0,0.04); cursor: pointer;
transition: all 0.2s; position: relative; overflow: hidden;
}
.account-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 16px 16px 0 0; }
.account-card.status-active::before { background: linear-gradient(90deg, #10b981, #34d399); }
.account-card.status-pending::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.account-card.status-invalid_cookie::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.account-card.status-banned::before { background: linear-gradient(90deg, #6b7280, #9ca3af); }
.account-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 30px rgba(99,102,241,0.12);
}
.account-card-top {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 14px;
}
.account-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,0.1); }
.account-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.account-avatar {
width: 48px; height: 48px;
border-radius: 16px;
width: 40px; height: 40px; border-radius: 12px;
background: linear-gradient(135deg, #6366f1, #a855f7);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20px;
font-weight: 700;
flex-shrink: 0;
}
.account-name {
font-size: 16px;
font-weight: 700;
color: #1e293b;
margin-bottom: 4px;
word-break: break-all;
}
.account-remark {
font-size: 13px;
color: #94a3b8;
margin-bottom: 14px;
display: flex; align-items: center; justify-content: center;
color: white; font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.account-name { font-size: 15px; font-weight: 700; color: #1e293b; word-break: break-all; }
.account-remark { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.account-meta {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 14px;
border-top: 1px solid #f1f5f9;
display: flex; justify-content: space-between; align-items: center;
padding-top: 10px; border-top: 1px solid #f1f5f9;
}
.account-date { font-size: 12px; color: #cbd5e1; }
/* 删除按钮 */
.account-date { font-size: 11px; color: #cbd5e1; }
.account-del-btn {
width: 32px; height: 32px;
border-radius: 10px;
border: 1.5px solid #fecaca;
background: #fff;
color: #ef4444;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
flex-shrink: 0;
width: 28px; height: 28px; border-radius: 8px; border: 1.5px solid #fecaca;
background: #fff; color: #ef4444; font-size: 12px; cursor: pointer;
display: flex; align-items: center; justify-content: center;
}
.account-del-btn:hover {
background: #fef2f2;
border-color: #f87171;
.account-del-btn:hover { background: #fef2f2; }
.batch-bar {
background: rgba(255,255,255,0.9); border-radius: 14px; padding: 12px 16px;
margin-bottom: 14px; border: 1px solid rgba(255,255,255,0.6);
display: flex; justify-content: space-between; align-items: center; gap: 10px;
flex-wrap: wrap;
}
/* 空状态 */
.batch-bar .info { font-size: 13px; color: #64748b; }
.empty-state {
text-align: center;
padding: 80px 20px;
background: rgba(255,255,255,0.7);
border-radius: 24px;
border: 2px dashed #e2e8f0;
text-align: center; padding: 60px 20px; background: rgba(255,255,255,0.7);
border-radius: 20px; border: 2px dashed #e2e8f0;
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state p { color: #94a3b8; margin-bottom: 24px; font-size: 16px; }
/* Cookie 批量验证 */
.batch-verify-bar {
background: rgba(255,255,255,0.9);
backdrop-filter: blur(8px);
border-radius: 20px;
padding: 16px 24px;
margin-bottom: 20px;
border: 1px solid rgba(255,255,255,0.6);
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
display: flex;
justify-content: space-between;
align-items: center;
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: #94a3b8; margin-bottom: 20px; font-size: 15px; }
@media (max-width: 768px) {
.stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card { padding: 12px; }
.stat-card .stat-value { font-size: 20px; }
.stat-card .stat-label { font-size: 11px; }
.account-grid { grid-template-columns: 1fr; }
.batch-bar { flex-direction: column; align-items: stretch; text-align: center; }
.batch-bar .info { margin-bottom: 8px; }
.dash-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
.batch-verify-bar .info { font-size: 14px; color: #64748b; }
.batch-verify-bar .info strong { color: #1e293b; }
</style>
{% endblock %}
{% block content %}
<div class="dash-header">
<h1>👋 控制台</h1>
<div class="dash-actions">
<a href="{{ url_for('add_account') }}" class="btn btn-primary">+ 添加账号</a>
</div>
<a href="{{ url_for('add_account') }}" class="btn btn-primary">+ 添加账号</a>
</div>
{% if accounts %}
<!-- 统计概览 -->
{% set sc = pagination.get('status_counts', {}) %}
{% set total_accounts = pagination.get('total', 0) %}
{% set active_count = sc.get('active', 0) %}
{% set need_attention = sc.get('pending', 0) + sc.get('invalid_cookie', 0) %}
{% if total_accounts > 0 %}
<div class="stats-row">
<div class="stat-card">
<div class="stat-icon">📊</div>
<div class="stat-value">{{ accounts|length }}</div>
<div class="stat-value">{{ total_accounts }}</div>
<div class="stat-label">账号总数</div>
</div>
<div class="stat-card">
<div class="stat-icon"></div>
<div class="stat-value">{{ accounts|selectattr('status','equalto','active')|list|length }}</div>
<div class="stat-value">{{ active_count }}</div>
<div class="stat-label">正常运行</div>
</div>
<div class="stat-card">
<div class="stat-icon">⚠️</div>
<div class="stat-value">{{ accounts|selectattr('status','equalto','pending')|list|length + accounts|selectattr('status','equalto','invalid_cookie')|list|length }}</div>
<div class="stat-value">{{ need_attention }}</div>
<div class="stat-label">需要关注</div>
</div>
</div>
<!-- 批量操作栏 -->
<div class="batch-verify-bar">
<div class="info">
💡 系统每天 <strong>23:50</strong> 自动批量验证 Cookie也可手动触发
</div>
<div style="display:flex; gap:10px;">
<button class="btn btn-secondary" id="batch-verify-btn" onclick="batchVerify()">🔍 批量验证 Cookie</button>
<div class="batch-bar">
<div class="info">💡 可手动触发批量操作</div>
<div style="display:flex; gap:8px; flex-wrap:wrap;">
<button class="btn btn-secondary" id="batch-verify-btn" onclick="batchVerify()">🔍 批量验证</button>
<button class="btn btn-primary" id="batch-signin-btn" onclick="batchSignin()">🚀 全部签到</button>
</div>
</div>
<!-- 账号卡片 -->
<div class="account-grid">
{% for account in accounts %}
<div class="account-card status-{{ account.status }}" onclick="window.location.href='{{ url_for('account_detail', account_id=account.id) }}'">
@@ -210,87 +123,88 @@
</div>
<div class="account-meta">
<div>
{% if account.status == 'active' %}
<span class="badge badge-success">正常</span>
{% elif account.status == 'pending' %}
<span class="badge badge-warning">待验证</span>
{% elif account.status == 'invalid_cookie' %}
<span class="badge badge-danger">Cookie 失效</span>
{% elif account.status == 'banned' %}
<span class="badge badge-danger">已封禁</span>
{% if account.status == 'active' %}<span class="badge badge-success">正常</span>
{% elif account.status == 'pending' %}<span class="badge badge-warning">待验证</span>
{% elif account.status == 'invalid_cookie' %}<span class="badge badge-danger">Cookie 失效</span>
{% elif account.status == 'banned' %}<span class="badge badge-danger">已封禁</span>
{% endif %}
</div>
<div style="display:flex; align-items:center; gap:10px;">
<div style="display:flex; align-items:center; gap:8px;">
<span class="account-date">{{ account.created_at[:10] }}</span>
<button class="account-del-btn" title="删除账号" onclick="event.stopPropagation(); deleteAccount('{{ account.id }}', '{{ account.remark or account.weibo_user_id }}');">🗑</button>
<button class="account-del-btn" title="删除" onclick="event.stopPropagation(); deleteAccount('{{ account.id }}', '{{ account.remark or account.weibo_user_id }}');">🗑</button>
</div>
</div>
</div>
{% endfor %}
</div>
{% if pagination.get('total_pages', 0) > 1 %}
<div class="pagination">
{% set p = pagination.page %}
{% set tp = pagination.total_pages %}
{% if p > 1 %}
<a href="?page={{ p - 1 }}"> 上一页</a>
{% else %}
<span class="disabled"> 上一页</span>
{% endif %}
{% for i in range(max(1, p - 2), min(tp, p + 2) + 1) %}
{% if i == p %}<span class="active">{{ i }}</span>
{% else %}<a href="?page={{ i }}">{{ i }}</a>{% endif %}
{% endfor %}
{% if p < tp %}
<a href="?page={{ p + 1 }}">下一页 </a>
{% else %}
<span class="disabled">下一页 </span>
{% endif %}
</div>
{% endif %}
{% else %}
<div class="empty-state">
<div class="empty-icon">📱</div>
<p>暂无账号,扫码添加你的微博账号开始自动签到</p>
<a href="{{ url_for('add_account') }}" class="btn btn-primary" style="font-size:16px; padding:14px 32px;">添加第一个账号</a>
<a href="{{ url_for('add_account') }}" class="btn btn-primary" style="padding:12px 28px;">添加第一个账号</a>
</div>
{% endif %}
<script>
async function deleteAccount(accountId, name) {
if (!confirm(`确定要删除账号「${name}」吗?此操作不可恢复。`)) return;
try {
const form = document.createElement('form');
form.method = 'POST';
form.action = `/accounts/${accountId}/delete`;
document.body.appendChild(form);
form.submit();
} catch(e) {
alert('删除失败: ' + e.message);
}
async function deleteAccount(id, name) {
if (!confirm(`确定要删除账号「${name}」吗?`)) return;
const form = document.createElement('form');
form.method = 'POST';
form.action = `/accounts/${id}/delete`;
document.body.appendChild(form);
form.submit();
}
async function batchVerify() {
const btn = document.getElementById('batch-verify-btn');
btn.disabled = true;
btn.textContent = '⏳ 验证中...';
btn.disabled = true; btn.textContent = '⏳ 验证中...';
try {
const resp = await fetch('/api/batch/verify', {method: 'POST'});
const data = await resp.json();
if (data.success) {
const r = data.data;
alert(`验证完成:${r.valid} 有效,${r.invalid} 失效,${r.errors} 出错`);
} else {
alert('验证失败: ' + (data.message || '未知错误'));
}
} catch(e) {
alert('请求失败: ' + e.message);
}
btn.disabled = false;
btn.textContent = '🔍 批量验证 Cookie';
alert(`验证完成:${r.valid} 有效,${r.invalid} 失效,${r.errors} 出错`);
} else { alert('验证失败: ' + (data.message || '未知错误')); }
} catch(e) { alert('请求失败: ' + e.message); }
btn.disabled = false; btn.textContent = '🔍 批量验证';
location.reload();
}
async function batchSignin() {
const btn = document.getElementById('batch-signin-btn');
if (!confirm('确定要对所有正常账号执行签到吗?')) return;
btn.disabled = true;
btn.textContent = '⏳ 签到中...';
btn.disabled = true; btn.textContent = '⏳ 签到中...';
try {
const resp = await fetch('/api/batch/signin', {method: 'POST'});
const data = await resp.json();
if (data.success) {
const r = data.data;
alert(`签到完成:${r.total_accounts} 个账号,${r.total_signed} 成功,${r.total_already} 已签,${r.total_failed} 失败`);
} else {
alert('签到失败: ' + (data.message || '未知错误'));
}
} catch(e) {
alert('请求失败: ' + e.message);
}
btn.disabled = false;
btn.textContent = '🚀 全部签到';
} else { alert('签到失败: ' + (data.message || '未知错误')); }
} catch(e) { alert('请求失败: ' + e.message); }
btn.disabled = false; btn.textContent = '🚀 全部签到';
location.reload();
}
</script>