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:
490
templates/index.html
Normal file
490
templates/index.html
Normal 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>
|
||||
Reference in New Issue
Block a user