initial commit: Go version of SMS Receiver with fixed template rendering

- Implemented all core features from Python version
- Fixed int64/int type compatibility in template functions
- Added login authentication, SMS receiving, statistics, logs
- Independent database: sms_receiver_go.db
- Fixed frontend display issues for message list and statistics
This commit is contained in:
OpenClaw Agent
2026-02-08 17:15:22 +08:00
commit 4a31cd1115
23 changed files with 3493 additions and 0 deletions

564
templates/index.html Normal file
View File

@@ -0,0 +1,564 @@
<!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);
animation: slideInDown 0.5s ease-out;
}
.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.active {
background: #764ba2;
}
.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);
text-align: center;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
}
.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card h3 {
font-size: 14px;
color: #666;
margin-bottom: 10px;
}
.stat-card .value {
font-size: 28px;
font-weight: bold;
color: #333;
}
.from-numbers-filter {
background: white;
padding: 15px;
border-radius: 10px;
margin-bottom: 15px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.5s;
}
.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: all 0.3s;
}
.from-numbers-filter .tag:hover {
background: #667eea;
color: white;
}
.from-numbers-filter .tag.active {
background: #667eea;
color: white;
}
.toolbar {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
align-items: center;
background: white;
padding: 15px;
border-radius: 10px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.6s;
}
.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;
}
.auto-refresh-info {
display: flex;
align-items: center;
gap: 10px;
color: #666;
font-size: 14px;
}
.refresh-toggle {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 5px 10px;
background: #f0f0f0;
border-radius: 5px;
cursor: pointer;
user-select: none;
}
.refresh-toggle.active {
background: #d4edda;
color: #155724;
}
.messages-list {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.7s;
}
.list-view {
list-style: none;
}
.list-view li {
padding: 15px;
border-bottom: 1px solid #eee;
transition: background 0.3s;
}
.list-view li:hover {
background: #f9f9f9;
}
.list-view li:last-child {
border-bottom: none;
}
.msg-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.from-number {
font-weight: bold;
color: #667eea;
font-size: 15px;
}
.msg-time {
font-size: 12px;
color: #999;
}
.msg-content {
color: #333;
font-size: 14px;
line-height: 1.6;
word-break: break-all;
}
.sign-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
font-weight: bold;
margin-left: 10px;
}
.sign-badge.yes {
background: #d4edda;
color: #155724;
}
.sign-badge.no {
background: #f8d7da;
color: #721c24;
}
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 20px;
padding: 20px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.8s;
}
.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;
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #999;
}
.empty-state h3 {
margin-bottom: 10px;
color: #666;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInDown {
from {
opacity: 0;
transform: translateY(-30px);
}
to {
opacity: 1;
transform: translateY(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;
}
.nav {
justify-content: center;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📱 短信转发接收端</h1>
<div class="nav">
<a href="/" class="active">短信列表</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}} / {{add .stats.Verified .stats.Unverified}}</div>
</div>
</div>
{{if gt (len .fromNumbers) 0}}
<div class="from-numbers-filter">
<h3>快捷筛选 (按号码)</h3>
<div class="tags">
<span class="tag {{if eq .selectedFrom ""}}active{{end}}" onclick="filterByNumber('')">全部</span>
{{range .fromNumbers}}
<span class="tag {{if eq $.selectedFrom .}}active{{end}}" onclick="filterByNumber('{{.}}')">{{.}}</span>
{{end}}
</div>
</div>
{{end}}
<div class="toolbar">
<input type="text" id="searchInput" placeholder="搜索内容或号码..." value="{{.search}}">
<button onclick="search()">搜索</button>
<button onclick="clearSearch()">清除</button>
<div class="auto-refresh-info">
<span class="refresh-toggle active" id="refreshToggle">
<input type="checkbox" id="autoRefresh" checked onchange="toggleAutoRefresh()">
<span>自动刷新</span>
</span>
<span id="refreshCountdown">30s</span>
</div>
<div class="refresh-btn">
<button onclick="location.reload()">立即刷新</button>
</div>
</div>
<div class="messages-list">
{{if gt (len .messages) 0}}
<ul class="list-view">
{{range .messages}}
<li>
<div class="msg-header">
<span class="from-number">{{.FromNumber}}</span>
<span class="msg-time">{{if .LocalTimestampStr}}{{.LocalTimestampStr}}{{else}}{{.CreatedAt.Format "2006-01-02 15:04:05"}}{{end}}</span>
</div>
<div class="msg-content">
{{.Content}}
{{if .SignVerified.Valid}}
{{if .SignVerified.Bool}}
<span class="sign-badge yes">已验证</span>
{{else}}
<span class="sign-badge no">未验证</span>
{{end}}
{{end}}
</div>
</li>
{{end}}
</ul>
{{else}}
<div class="empty-state">
<h3>暂无短信</h3>
<p>等待接收短信...</p>
</div>
{{end}}
</div>
{{if gt .totalPages 1}}
<div class="pagination">
{{if gt .page 1}}
<a href="/?page={{sub .page 1}}&from={{.selectedFrom}}&search={{.search}}">上一页</a>
{{end}}
{{range $p := (seq 1 .totalPages)}}
{{if eq $p $.page}}
<span class="active">{{$p}}</span>
{{else if or (le $p 3) (ge $p (sub $.totalPages 2)) (and (ge $p (sub $.page 1)) (le $p (add $.page 1)))}}
<a href="/?page={{$p}}&from={{$.selectedFrom}}&search={{$.search}}">{{$p}}</a>
{{else if or (eq $p 4) (eq $p (sub $.totalPages 2))}}
<span>...</span>
{{end}}
{{end}}
{{if lt .page .totalPages}}
<a href="/?page={{add .page 1}}&from={{.selectedFrom}}&search={{.search}}">下一页</a>
{{end}}
<span>共 {{.total}} 条,第 {{.page}} / {{.totalPages}} 页</span>
</div>
{{end}}
</div>
<script>
let refreshInterval;
let countdownInterval;
let refreshCountdown = 30;
const REFRESH_INTERVAL = 30;
function search() {
const query = document.getElementById('searchInput').value;
window.location.href = '/?search=' + encodeURIComponent(query){{if .selectedFrom}}+ '&from={{.selectedFrom}}'{{end}};
}
function clearSearch() {
window.location.href = '/'{{if .selectedFrom}}+ '?from={{.selectedFrom}}'{{end}};
}
function filterByNumber(number) {
let url = '/';
const params = new URLSearchParams();
if (number) params.set('from', number);
{{if .search}}params.set('search', '{{.search}}');{{end}}
const qs = params.toString();
if (qs) url += '?' + qs;
window.location.href = url;
}
function toggleAutoRefresh() {
const checkbox = document.getElementById('autoRefresh');
const toggle = document.getElementById('refreshToggle');
if (checkbox.checked) {
toggle.classList.add('active');
startAutoRefresh();
} else {
toggle.classList.remove('active');
stopAutoRefresh();
}
}
function startAutoRefresh() {
refreshCountdown = REFRESH_INTERVAL;
updateCountdown();
refreshInterval = setInterval(() => {
const params = new URLSearchParams();
{{if .search}}params.set('search', '{{.search}}');{{end}}
{{if .selectedFrom}}params.set('from', '{{.selectedFrom}}');{{end}}
const qs = params.toString();
window.location.href = '/?' + qs;
}, 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';
}
document.getElementById('searchInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
search();
}
});
// 初始化自动刷新
document.addEventListener('DOMContentLoaded', function() {
startAutoRefresh();
});
</script>
</body>
</html>

130
templates/login.html Normal file
View File

@@ -0,0 +1,130 @@
<!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 {
width: 100%;
max-width: 400px;
animation: fadeInUp 0.5s ease-out;
}
.login-card {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.login-card h1 {
font-size: 24px;
color: #333;
text-align: center;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #555;
font-size: 14px;
}
.form-group input {
width: 100%;
padding: 12px 15px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
transition: border-color 0.3s;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
}
.form-group button {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: opacity 0.3s;
}
.form-group button:hover {
opacity: 0.9;
}
.error-message {
background: #f8d7da;
color: #721c24;
padding: 10px 15px;
border-radius: 5px;
margin-bottom: 20px;
font-size: 14px;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-card">
<h1>📱 短信转发接收端</h1>
{{if .error}}
<div class="error-message">{{.error}}</div>
{{end}}
<form method="POST" action="/login">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required placeholder="请输入用户名">
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required placeholder="请输入密码">
</div>
<div class="form-group">
<button type="submit">登录</button>
</div>
</form>
</div>
</div>
</body>
</html>

371
templates/logs.html Normal file
View File

@@ -0,0 +1,371 @@
<!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);
animation: slideInDown 0.5s ease-out;
}
.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 a.active {
background: #764ba2;
}
.nav .logout {
background: #dc3545;
}
.nav .logout:hover {
background: #c82333;
}
.toolbar {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
align-items: center;
background: white;
padding: 15px;
border-radius: 10px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.4s;
}
.auto-refresh-info {
display: flex;
align-items: center;
gap: 10px;
color: #666;
font-size: 14px;
}
.refresh-toggle {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 5px 10px;
background: #f0f0f0;
border-radius: 5px;
cursor: pointer;
user-select: none;
}
.refresh-toggle.active {
background: #d4edda;
color: #155724;
}
.logs-list {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.5s;
}
.logs-list table {
width: 100%;
border-collapse: collapse;
}
.logs-list th, .logs-list td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #eee;
}
.logs-list th {
background-color: #f8f9fa;
font-weight: 600;
color: #555;
}
.logs-list tr:hover {
background-color: #f9f9f9;
}
.status-badge {
display: inline-block;
padding: 4px 10px;
border-radius: 10px;
font-size: 12px;
font-weight: bold;
}
.status-badge.success {
background: #d4edda;
color: #155724;
}
.status-badge.error {
background: #f8d7da;
color: #721c24;
}
.sign-badge {
font-size: 16px;
}
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 20px;
padding: 20px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.6s;
}
.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;
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #999;
}
.empty-state h3 {
margin-bottom: 10px;
color: #666;
}
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInDown {
from { opacity: 0; transform: translateY(-30px); }
to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
.header { flex-direction: column; gap: 15px; }
.nav { justify-content: center; }
.toolbar { flex-direction: column; align-items: stretch; }
.logs-list { overflow-x: auto; }
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📋 接收日志</h1>
<div class="nav">
<a href="/">短信列表</a>
<a href="/logs" class="active">接收日志</a>
<a href="/statistics">统计信息</a>
<a href="/logout" class="logout">退出登录</a>
</div>
</div>
<div class="toolbar">
<span style="color: #666;">自动刷新</span>
<div class="auto-refresh-info">
<span class="refresh-toggle active" id="refreshToggle">
<input type="checkbox" id="autoRefresh" checked onchange="toggleAutoRefresh()">
<span>启用</span>
</span>
<span id="refreshCountdown">30s</span>
</div>
<div class="refresh-btn">
<button onclick="location.reload()">立即刷新</button>
</div>
</div>
<div class="logs-list">
{{if gt (len .logs) 0}}
<table>
<thead>
<tr>
<th>ID</th>
<th>号码</th>
<th>内容</th>
<th>时间</th>
<th>签名</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{{range .logs}}
<tr>
<td>{{.ID}}</td>
<td>{{.FromNumber}}</td>
<td style="max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{.Content}}</td>
<td>{{.CreatedAt.Format "2006-01-02 15:04:05"}}</td>
<td>
{{if .SignValid.Valid}}
{{if .SignValid.Bool}}
<span class="sign-badge"></span>
{{else}}
<span class="sign-badge"></span>
{{end}}
{{else}}
<span style="color: #999;">-</span>
{{end}}
</td>
<td>
{{if eq .Status "success"}}
<span class="status-badge success">成功</span>
{{else}}
<span class="status-badge error">失败</span>
{{if .ErrorMessage.Valid}}
<br><small style="color: #e74c3c;">{{.ErrorMessage.String}}</small>
{{end}}
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<div class="empty-state">
<h3>暂无日志</h3>
</div>
{{end}}
</div>
{{if gt .totalPages 1}}
<div class="pagination">
{{if gt .page 1}}
<a href="/logs?page={{sub .page 1}}">上一页</a>
{{end}}
{{range $p := (seq 1 .totalPages)}}
{{if eq $p $.page}}
<span class="active">{{$p}}</span>
{{else if or (le $p 3) (ge $p (sub $.totalPages 2)) (and (ge $p (sub $.page 1)) (le $p (add $.page 1)))}}
<a href="/logs?page={{$p}}">{{$p}}</a>
{{else if or (eq $p 4) (eq $p (sub $.totalPages 2))}}
<span>...</span>
{{end}}
{{end}}
{{if lt .page .totalPages}}
<a href="/logs?page={{add .page 1}}">下一页</a>
{{end}}
<span>共 {{.total}} 条,第 {{.page}} / {{.totalPages}} 页</span>
</div>
{{end}}
</div>
<script>
let refreshInterval;
let countdownInterval;
let refreshCountdown = 30;
const REFRESH_INTERVAL = 30;
function toggleAutoRefresh() {
const checkbox = document.getElementById('autoRefresh');
const toggle = document.getElementById('refreshToggle');
if (checkbox.checked) {
toggle.classList.add('active');
startAutoRefresh();
} else {
toggle.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';
}
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('autoRefresh').addEventListener('change', toggleAutoRefresh);
startAutoRefresh();
});
</script>
</body>
</html>

View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>短信详情 - 短信转发接收端</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div class="container">
<nav class="navbar">
<div class="nav-brand">📱 短信转发接收端</div>
<div class="nav-links">
<a href="/">短信列表</a>
<a href="/logs">接收日志</a>
<a href="/statistics">统计信息</a>
<a href="/logout">退出</a>
</div>
</nav>
<main class="content">
<div class="detail-container">
<h2>📱 短信详情</h2>
<a href="/" style="color: #667eea; text-decoration: none;">← 返回列表</a>
<div class="detail-item" style="margin-top: 20px;">
<div class="detail-label">ID</div>
<div class="detail-value">{{.ID}}</div>
</div>
<div class="detail-item">
<div class="detail-label">发送方号码</div>
<div class="detail-value">{{.FromNumber}}</div>
</div>
<div class="detail-item">
<div class="detail-label">短信内容</div>
<div class="detail-value" style="white-space: pre-wrap;">{{.Content}}</div>
</div>
<div class="detail-item">
<div class="detail-label">原始时间戳</div>
<div class="detail-value">{{.Timestamp}}</div>
</div>
<div class="detail-item">
<div class="detail-label">本地时间</div>
<div class="detail-value">{{.TimestampStr}}</div>
</div>
<div class="detail-item">
<div class="detail-label">入库时间</div>
<div class="detail-value">{{.CreatedAt.Format "2006-01-02 15:04:05"}}</div>
</div>
<div class="detail-item">
<div class="detail-label">签名验证</div>
<div class="detail-value">
{{if .SignVerified.Valid}}
{{if .SignVerified.Bool}}
<span class="badge badge-success">已验证</span>
{{else}}
<span class="badge badge-danger">未验证</span>
{{end}}
{{else}}
<span class="badge badge-warning">未验证</span>
{{end}}
</div>
</div>
{{if .DeviceInfo.Valid}}
<div class="detail-item">
<div class="detail-label">设备信息</div>
<div class="detail-value">{{.DeviceInfo.String}}</div>
</div>
{{end}}
{{if .SIMInfo.Valid}}
<div class="detail-item">
<div class="detail-label">SIM 卡信息</div>
<div class="detail-value">{{.SIMInfo.String}}</div>
</div>
{{end}}
<div class="detail-item">
<div class="detail-label">IP 地址</div>
<div class="detail-value">{{.IPAddress}}</div>
</div>
</div>
</main>
</div>
</body>
</html>

284
templates/statistics.html Normal file
View File

@@ -0,0 +1,284 @@
<!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);
animation: slideInDown 0.5s ease-out;
}
.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 a.active {
background: #764ba2;
}
.nav .logout {
background: #dc3545;
}
.nav .logout:hover {
background: #c82333;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-bottom: 30px;
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
}
.stats .stat-card:nth-child(1) { animation-delay: 0.1s; }
.stats .stat-card:nth-child(2) { animation-delay: 0.2s; }
.stats .stat-card:nth-child(3) { animation-delay: 0.3s; }
.stats .stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card {
background: white;
padding: 30px 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
}
.stat-card h3 {
font-size: 14px;
color: #666;
margin-bottom: 15px;
}
.stat-card .value {
font-size: 36px;
font-weight: bold;
color: #333;
}
.stat-card.blue { border-top: 4px solid #667eea; }
.stat-card.green { border-top: 4px solid #38ef7d; }
.stat-card.orange { border-top: 4px solid #f5576c; }
.stat-card.purple { border-top: 4px solid #764ba2; }
.detail-section {
background: white;
border-radius: 10px;
padding: 25px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
animation-delay: 0.5s;
}
.detail-section h2 {
font-size: 18px;
color: #333;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.detail-section table {
width: 100%;
border-collapse: collapse;
}
.detail-section td {
padding: 15px;
border-bottom: 1px solid #eee;
}
.detail-section td:first-child {
color: #666;
width: 150px;
}
.detail-section tr:hover {
background-color: #f9f9f9;
}
.badge {
display: inline-block;
padding: 4px 12px;
border-radius: 10px;
font-size: 14px;
font-weight: bold;
}
.badge-success {
background: #d4edda;
color: #155724;
}
.badge-warning {
background: #fff3cd;
color: #856404;
}
.badge-danger {
background: #f8d7da;
color: #721c24;
}
.progress-bar {
width: 100%;
height: 20px;
background: #f0f0f0;
border-radius: 10px;
overflow: hidden;
margin-top: 10px;
}
.progress-bar .fill {
height: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
transition: width 0.5s ease;
}
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInDown {
from { opacity: 0; transform: translateY(-30px); }
to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
.header { flex-direction: column; gap: 15px; }
.nav { justify-content: center; }
.stats { grid-template-columns: 1fr 1fr; }
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📊 统计信息</h1>
<div class="nav">
<a href="/">短信列表</a>
<a href="/logs">接收日志</a>
<a href="/statistics" class="active">统计信息</a>
<a href="/logout" class="logout">退出登录</a>
</div>
</div>
<div class="stats">
<div class="stat-card blue">
<h3>短信总数</h3>
<div class="value">{{.stats.Total}}</div>
</div>
<div class="stat-card green">
<h3>今日短信</h3>
<div class="value">{{.stats.Today}}</div>
</div>
<div class="stat-card orange">
<h3>本周短信</h3>
<div class="value">{{.stats.Week}}</div>
</div>
<div class="stat-card purple">
<h3>签名验证</h3>
<div class="value">{{add .stats.Verified .stats.Unverified}}</div>
</div>
</div>
<div class="detail-section">
<h2>签名验证详情</h2>
<table>
<tr>
<td>已验证签名</td>
<td>
<span class="badge badge-success">{{.stats.Verified}} 条</span>
</td>
</tr>
<tr>
<td>未验证签名</td>
<td>
{{if .stats.Unverified}}
<span class="badge badge-warning">{{.stats.Unverified}} 条</span>
{{else}}
<span class="badge badge-success">0 条</span>
{{end}}
</td>
</tr>
<tr>
<td>验证通过率</td>
<td>
{{if .stats.Total}}
{{if .stats.Verified}}
<span class="badge badge-success">{{printf "%.1f" (mulFloat .stats.Verified .stats.Total)}}%</span>
{{else}}
<span class="badge badge-warning">0%</span>
{{end}}
{{else}}
<span style="color: #999;">N/A</span>
{{end}}
</td>
</tr>
</table>
{{if .stats.Total}}
{{$verified := .stats.Verified}}
{{$total := .stats.Total}}
<div class="progress-bar">
<div class="fill" style="width: {{mulFloat $verified $total}}%"></div>
</div>
<p style="margin-top: 10px; color: #666; font-size: 14px;">
已验证 {{.stats.Verified}} / 总数 {{.stats.Total}}
</p>
{{end}}
</div>
</div>
</body>
</html>