Initial commit: SMS Receiver Web Service

Features:
- Receive SMS from TranspondSms Android APP
- HMAC-SHA256 signature verification (optional)
- SQLite database storage
- Web UI with login authentication
- Multiple API tokens support
- Timezone conversion (Asia/Shanghai)
- Search, filter, and statistics
- Auto refresh and session management

Tech Stack:
- Flask 3.0
- SQLite database
- HTML5/CSS3 responsive design
This commit is contained in:
OpenClaw Agent
2026-02-06 23:23:49 +00:00
commit 4e5e93660d
16 changed files with 3754 additions and 0 deletions

73
templates/error.html Normal file
View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>错误</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.error-container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
max-width: 500px;
}
.error-icon {
font-size: 64px;
margin-bottom: 20px;
}
.error-container h1 {
font-size: 28px;
color: #333;
margin-bottom: 15px;
}
.error-container p {
color: #666;
font-size: 16px;
margin-bottom: 25px;
}
.error-container a {
display: inline-block;
padding: 12px 24px;
background: #667eea;
color: white;
text-decoration: none;
border-radius: 5px;
transition: background 0.3s;
}
.error-container a:hover {
background: #764ba2;
}
</style>
</head>
<body>
<div class="error-container">
<div class="error-icon">⚠️</div>
<h1>{{ error or '出错了' }}</h1>
<p>抱歉,遇到了一些问题,请稍后再试。</p>
<a href="/">返回首页</a>
</div>
</body>
</html>

490
templates/index.html Normal file
View File

@@ -0,0 +1,490 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>短信转发接收端</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.header h1 {
font-size: 24px;
color: #333;
}
.nav {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.nav a {
padding: 8px 16px;
text-decoration: none;
background: #667eea;
color: white;
border-radius: 5px;
transition: background 0.3s;
}
.nav a:hover {
background: #764ba2;
}
.nav .logout {
background: #dc3545;
}
.nav .logout:hover {
background: #c82333;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.stat-card {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.stat-card h3 {
font-size: 14px;
color: #666;
margin-bottom: 10px;
}
.stat-card .value {
font-size: 28px;
font-weight: bold;
color: #333;
}
.toolbar {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
align-items: center;
}
.toolbar input,
.toolbar select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 14px;
}
.toolbar button {
padding: 8px 16px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
.toolbar button:hover {
background: #764ba2;
}
.toolbar .refresh-btn {
margin-left: auto;
}
.messages-table {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.messages-table table {
width: 100%;
border-collapse: collapse;
}
.messages-table th,
.messages-table td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #eee;
}
.messages-table th {
background: #f5f5f5;
font-weight: 600;
color: #333;
}
.messages-table tr:hover {
background: #f9f9f9;
}
.from-number {
font-weight: bold;
color: #667eea;
}
.sign-verified {
display: inline-block;
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
font-weight: bold;
}
.sign-verified.yes {
background: #d4edda;
color: #155724;
}
.sign-verified.no {
background: #f8d7da;
color: #721c24;
}
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 20px;
}
.pagination a,
.pagination span {
padding: 8px 12px;
background: white;
border-radius: 5px;
text-decoration: none;
color: #333;
}
.pagination a:hover {
background: #667eea;
color: white;
}
.pagination span.active {
background: #667eea;
color: white;
}
.from-numbers-filter {
background: white;
padding: 15px;
border-radius: 10px;
margin-bottom: 15px;
}
.from-numbers-filter h3 {
font-size: 14px;
color: #666;
margin-bottom: 10px;
}
.from-numbers-filter .tags {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.from-numbers-filter .tag {
padding: 5px 10px;
background: #f0f0f0;
border-radius: 5px;
font-size: 12px;
cursor: pointer;
transition: background 0.3s;
}
.from-numbers-filter .tag:hover {
background: #667eea;
color: white;
}
.empty-state {
text-align: center;
padding: 40px;
color: #999;
}
.auto-refresh {
margin-left: 20px;
font-size: 12px;
color: #666;
}
.refresh-toggle {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 8px 12px;
background: #f0f0f0;
border-radius: 5px;
cursor: pointer;
user-select: none;
}
.refresh-toggle.active {
background: #d4edda;
color: #155724;
}
.refresh-toggle input[type="checkbox"] {
margin: 0;
}
@media (max-width: 768px) {
.header {
flex-direction: column;
gap: 15px;
}
.stats {
grid-template-columns: 1fr 1fr;
}
.toolbar {
flex-direction: column;
align-items: stretch;
}
.toolbar .refresh-btn {
margin-left: 0;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📱 短信转发接收端</h1>
<div class="nav">
<a href="/">短信列表</a>
<a href="/logs">接收日志</a>
<a href="/statistics">统计信息</a>
<a href="/logout" class="logout">退出登录</a>
</div>
</div>
<div class="stats">
<div class="stat-card">
<h3>短信总数</h3>
<div class="value">{{ stats.total }}</div>
</div>
<div class="stat-card">
<h3>今日</h3>
<div class="value">{{ stats.today }}</div>
</div>
<div class="stat-card">
<h3>本周</h3>
<div class="value">{{ stats.week }}</div>
</div>
<div class="stat-card">
<h3>签名验证</h3>
<div class="value">
{{ stats.verified }} / {{ stats.verified + stats.unverified }}
</div>
</div>
</div>
<div class="from-numbers-filter">
<h3>快捷筛选 (按号码)</h3>
<div class="tags">
{% for num in from_numbers %}
<span class="tag" onclick="filterByNumber('{{ num.from_number }}')">
{{ num.from_number }} ({{ num.count }})
</span>
{% endfor %}
</div>
</div>
<div class="toolbar">
<input type="text" id="searchInput" placeholder="搜索内容或号码..." value="{{ search }}">
<button onclick="search()">搜索</button>
<button onclick="clearSearch()">清除</button>
<span class="auto-refresh">
<label class="refresh-toggle" id="refreshToggle">
<input type="checkbox" id="autoRefresh" checked>
<span>自动刷新</span>
</label>
<span id="refreshCountdown">{{ refresh_interval }}s</span>
</span>
<div class="refresh-btn">
<button onclick="location.reload()">立即刷新</button>
</div>
</div>
<div class="messages-table">
{% if messages %}
<table>
<thead>
<tr>
<th>ID</th>
<th>发送方</th>
<th>内容</th>
<th>时间</th>
<th>验证</th>
</tr>
</thead>
<tbody>
{% for msg in messages %}
<tr>
<td>{{ msg.id }}</td>
<td><span class="from-number">{{ msg.from_number }}</span></td>
<td>
<a href="/message/{{ msg.id }}" style="color: #333; text-decoration: none;">
{{ msg.content[:50] }}{% if msg.content|length > 50 %}...{% endif %}
</a>
</td>
<td>{{ msg.created_at }}</td>
<td>
{% if msg.sign_verified %}
<span class="sign-verified yes">✓ 已验证</span>
{% else %}
<span class="sign-verified no">✗ 未验证</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-state">
<h3>暂无短信数据</h3>
<p>等待接收短信...</p>
</div>
{% endif %}
</div>
{% if total_pages > 1 %}
<div class="pagination">
{% if page > 1 %}
<a href="?page={{ page - 1 }}&from={{ from_number }}&search={{ search }}&limit={{ limit }}">上一页</a>
{% endif %}
{% for p in range(1, total_pages + 1) %}
{% if p == page %}
<span class="active">{{ p }}</span>
{% elif p <= 3 or p >= total_pages - 2 or (p >= page - 1 and p <= page + 1) %}
<a href="?page={{ p }}&from={{ from_number }}&search={{ search }}&limit={{ limit }}">{{ p }}</a>
{% elif p == 4 or p == total_pages - 3 %}
<span>...</span>
{% endif %}
{% endfor %}
{% if page < total_pages %}
<a href="?page={{ page + 1 }}&from={{ from_number }}&search={{ search }}&limit={{ limit }}">下一页</a>
{% endif %}
<span>共 {{ total }} 条,第 {{ page }} / {{ total_pages }} 页</span>
</div>
{% endif %}
</div>
<script>
let refreshInterval;
let countdownInterval;
let refreshCountdown = {{ refresh_interval }};
function search() {
const query = document.getElementById('searchInput').value;
window.location.href = `/?search=${encodeURIComponent(query)}&from={{ from_number }}&limit={{ limit }}`;
}
function clearSearch() {
window.location.href = '/';
}
function filterByNumber(number) {
window.location.href = `/?from=${encodeURIComponent(number)}&limit={{ limit }}`;
}
function autoRefresh() {
const autoRefreshCheckbox = document.getElementById('autoRefresh');
const refreshToggle = document.getElementById('refreshToggle');
if (autoRefreshCheckbox.checked) {
refreshToggle.classList.add('active');
startAutoRefresh();
} else {
refreshToggle.classList.remove('active');
stopAutoRefresh();
}
}
function startAutoRefresh() {
refreshCountdown = {{ refresh_interval }};
updateCountdown();
refreshInterval = setInterval(() => {
location.reload();
}, {{ refresh_interval * 1000 }});
countdownInterval = setInterval(() => {
refreshCountdown--;
updateCountdown();
}, 1000);
}
function stopAutoRefresh() {
clearInterval(refreshInterval);
clearInterval(countdownInterval);
document.getElementById('refreshCountdown').textContent = '--s';
}
function updateCountdown() {
document.getElementById('refreshCountdown').textContent = `${refreshCountdown}s`;
}
// Enter 键搜索
document.getElementById('searchInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
search();
}
});
// 初始化自动刷新
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('autoRefresh').addEventListener('change', autoRefresh);
startAutoRefresh();
});
</script>
</body>
</html>

156
templates/login.html Normal file
View File

@@ -0,0 +1,156 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - 短信转发接收端</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.login-container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 400px;
}
.login-header {
text-align: center;
margin-bottom: 30px;
}
.login-header h1 {
font-size: 24px;
color: #333;
margin-bottom: 10px;
}
.login-header p {
color: #666;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-weight: 600;
color: #333;
margin-bottom: 8px;
font-size: 14px;
}
.form-group input {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 14px;
transition: border-color 0.3s;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
}
.login-btn {
width: 100%;
padding: 12px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s;
}
.login-btn:hover {
background: #764ba2;
}
.alert {
padding: 12px;
border-radius: 5px;
margin-bottom: 20px;
font-size: 14px;
}
.alert.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.alert.info {
background: #d1ecf1;
color: #0c5460;
border: 1px solid #bee5eb;
}
.flash-messages {
margin-bottom: 20px;
}
@media (max-width: 480px) {
.login-container {
padding: 30px 20px;
}
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-header">
<h1>📱 短信转发接收端</h1>
<p>请登录以继续</p>
</div>
<div class="flash-messages">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert {{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
</div>
<form method="POST" action="{{ url_for('login', next=request.args.get('next')) }}">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" placeholder="请输入用户名" required autofocus>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" placeholder="请输入密码" required>
</div>
<button type="submit" class="login-btn">登录</button>
</form>
</div>
</body>
</html>

195
templates/logs.html Normal file
View File

@@ -0,0 +1,195 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>接收日志</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.header h1 {
font-size: 24px;
color: #333;
}
.header .nav a {
padding: 8px 16px;
text-decoration: none;
background: #667eea;
color: white;
border-radius: 5px;
transition: background 0.3s;
}
.header .nav a:hover {
background: #764ba2;
}
.logs-table {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.logs-table table {
width: 100%;
border-collapse: collapse;
}
.logs-table th,
.logs-table td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #eee;
}
.logs-table th {
background: #f5f5f5;
font-weight: 600;
color: #333;
}
.logs-table tr:hover {
background: #f9f9f9;
}
.status {
display: inline-block;
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
font-weight: bold;
}
.status.success {
background: #d4edda;
color: #155724;
}
.status.error {
background: #f8d7da;
color: #721c24;
}
.sign-valid {
display: inline-block;
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
}
.sign-valid.yes {
background: #d4edda;
color: #155724;
}
.sign-valid.no {
background: #f8d7da;
color: #721c24;
}
.empty-state {
text-align: center;
padding: 40px;
color: #999;
}
@media (max-width: 768px) {
.header {
flex-direction: column;
gap: 15px;
text-align: center;
}
.logs-table {
overflow-x: auto;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📋 接收日志</h1>
<div class="nav">
<a href="/">返回列表</a>
</div>
</div>
<div class="logs-table">
{% if logs %}
<table>
<thead>
<tr>
<th>时间</th>
<th>发送方</th>
<th>状态</th>
<th>签名</th>
<th>IP 地址</th>
<th>错误信息</th>
</tr>
</thead>
<tbody>
{% for log in logs %}
<tr>
<td>{{ log.created_at }}</td>
<td>{{ log.from_number or '-' }}</td>
<td>
<span class="status {{ log.status }}">
{% if log.status == 'success' %}✓ 成功{% else %}✗ 失败{% endif %}
</span>
</td>
<td>
{% if log.sign_valid is not none %}
{% if log.sign_valid %}
<span class="sign-valid yes"></span>
{% else %}
<span class="sign-valid no"></span>
{% endif %}
{% else %}
-
{% endif %}
</td>
<td>{{ log.ip_address or '-' }}</td>
<td>{{ log.error_message or '-' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="empty-state">
<h3>暂无日志数据</h3>
</div>
{% endif %}
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,225 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>短信详情 #{{ message.id }}</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
}
.card {
background: white;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.card-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h1 {
font-size: 20px;
}
.card-header .nav {
display: flex;
gap: 10px;
}
.card-header a {
padding: 8px 16px;
text-decoration: none;
background: rgba(255, 255, 255, 0.2);
color: white;
border-radius: 5px;
transition: background 0.3s;
}
.card-header a:hover {
background: rgba(255, 255, 255, 0.3);
}
.card-body {
padding: 30px;
}
.field {
margin-bottom: 20px;
}
.field label {
display: block;
font-weight: 600;
color: #666;
margin-bottom: 8px;
font-size: 14px;
}
.field .value {
padding: 15px;
background: #f5f5f5;
border-radius: 5px;
color: #333;
word-break: break-all;
}
.field .value.from-number {
font-size: 18px;
color: #667eea;
font-weight: bold;
}
.field .value.content {
font-size: 16px;
line-height: 1.6;
}
.field .value.timestamp {
font-family: monospace;
}
.meta {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.meta .field .value {
font-size: 14px;
}
.sign-verified {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-weight: bold;
}
.sign-verified.yes {
background: #d4edda;
color: #155724;
}
.sign-verified.no {
background: #f8d7da;
color: #721c24;
}
@media (max-width: 768px) {
.meta {
grid-template-columns: 1fr;
}
.card-header {
flex-direction: column;
gap: 15px;
text-align: center;
}
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header">
<h1>📱 短信详情 #{{ message.id }}</h1>
<div class="nav">
<a href="/">返回列表</a>
</div>
</div>
<div class="card-body">
<div class="field">
<label>发送方号码</label>
<div class="value from-number">{{ message.from_number }}</div>
</div>
<div class="field">
<label>短信内容</label>
<div class="value content">{{ message.content }}</div>
</div>
<div class="meta">
<div class="field">
<label>接收时间</label>
<div class="value timestamp">{{ message.created_at }}</div>
</div>
<div class="field">
<label>原始时间戳</label>
<div class="value timestamp">
{% if message.timestamp %}
{{ message.timestamp }} ms
{% else %}
N/A
{% endif %}
</div>
</div>
<div class="field">
<label>签名验证</label>
<div class="value">
{% if message.sign_verified %}
<span class="sign-verified yes">✓ 已验证</span>
{% else %}
<span class="sign-verified no">✗ 未验证</span>
{% endif %}
</div>
</div>
<div class="field">
<label>来源 IP</label>
<div class="value">
{% if message.ip_address %}
{{ message.ip_address }}
{% else %}
N/A
{% endif %}
</div>
</div>
</div>
{% if message.device_info or message.sim_info %}
<div class="meta" style="margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee;">
{% if message.device_info %}
<div class="field">
<label>设备信息</label>
<div class="value">{{ message.device_info }}</div>
</div>
{% endif %}
{% if message.sim_info %}
<div class="field">
<label>SIM 卡信息</label>
<div class="value">{{ message.sim_info }}</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>
</div>
</body>
</html>

257
templates/statistics.html Normal file
View File

@@ -0,0 +1,257 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>统计信息</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.header {
margin-bottom: 20px;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
}
.header h1 {
font-size: 24px;
color: #333;
}
.header .nav a {
padding: 8px 16px;
text-decoration: none;
background: #667eea;
color: white;
border-radius: 5px;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 20px;
}
.stat-card {
background: white;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.stat-card h2 {
font-size: 16px;
color: #666;
margin-bottom: 10px;
}
.stat-card .value {
font-size: 36px;
font-weight: bold;
color: #333;
}
.stat-card .sub {
font-size: 12px;
color: #999;
margin-top: 5px;
}
.section {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
.section h3 {
font-size: 18px;
color: #333;
margin-bottom: 15px;
border-bottom: 2px solid #667eea;
padding-bottom: 10px;
}
.recent-list {
list-style: none;
}
.recent-list li {
padding: 15px;
border-bottom: 1px solid #eee;
}
.recent-list li:last-child {
border-bottom: none;
}
.recent-list .from {
font-weight: bold;
color: #667eea;
}
.recent-list .time {
font-size: 12px;
color: #999;
margin-left: 10px;
}
.recent-list .content {
color: #333;
margin-top: 5px;
}
.numbers-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
}
.number-card {
padding: 15px;
background: #f5f5f5;
border-radius: 5px;
}
.number-card .number {
font-weight: bold;
color: #667eea;
font-size: 16px;
}
.number-card .count {
color: #999;
font-size: 14px;
}
.cleanup-btn {
background: #dc3545;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
margin-top: 15px;
}
.cleanup-btn:hover {
background: #c82333;
}
@media (max-width: 768px) {
.header {
flex-direction: column;
gap: 15px;
text-align: center;
}
.stats-grid {
grid-template-columns: 1fr 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📊 统计信息</h1>
<div class="nav">
<a href="/">返回列表</a>
</div>
</div>
<div class="stats-grid">
<div class="stat-card">
<h2>短信总数</h2>
<div class="value">{{ stats.total }}</div>
<div class="sub">累计接收</div>
</div>
<div class="stat-card">
<h2>今日</h2>
<div class="value">{{ stats.today }}</div>
<div class="sub">今日新增</div>
</div>
<div class="stat-card">
<h2>本周</h2>
<div class="value">{{ stats.week }}</div>
<div class="sub">近7天</div>
</div>
<div class="stat-card">
<h2>签名验证</h2>
<div class="value">{{ stats.verified }} / {{ stats.verified + stats.unverified }}</div>
<div class="sub">已验证 / 总数</div>
</div>
</div>
<div class="section">
<h3>📬 最近接收</h3>
{% if recent %}
<ul class="recent-list">
{% for msg in recent %}
<li>
<span class="from">{{ msg.from_number }}</span>
<span class="time">{{ msg.created_at }}</span>
<div class="content">{{ msg.content[:100] }}{% if msg.content|length > 100 %}...{% endif %}</div>
</li>
{% endfor %}
</ul>
{% else %}
暂无数据
{% endif %}
</div>
<div class="section">
<h3>📱 发送方号码</h3>
{% if from_numbers %}
<div class="numbers-list">
{% for num in from_numbers %}
<div class="number-card">
<div class="number">{{ num.from_number }}</div>
<div class="count">{{ num.count }} 条短信</div>
</div>
{% endfor %}
</div>
{% else %}
暂无数据
{% endif %}
</div>
<div class="section">
<h3>🗑️ 数据清理</h3>
<p style="color: #666; margin-bottom: 15px;">
清理 {{ cleanup_days }} 天前的数据,最多保留 {{ max_messages }} 条
</p>
<button class="cleanup-btn" onclick="if(confirm('确定要清理旧数据吗?此操作不可恢复!')) { location.href='/cleanup'; }">
清理旧数据
</button>
</div>
</div>
</body>
</html>