forked from lengxi-root/QQBot-Webhook-to-WebSocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogs.html
More file actions
417 lines (380 loc) · 17 KB
/
logs.html
File metadata and controls
417 lines (380 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!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 href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/css/all.min.css" rel="stylesheet">
<style>
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.gradient-bg {
background: linear-gradient(-45deg, #1a1a1a, #2d3748, #1a202c, #2d3748);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
min-height: 100vh;
}
.card {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
border-radius: 1rem;
}
.stat-card {
transition: all 0.3s ease;
height: 100%;
}
.stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
background: rgba(255, 255, 255, 0.1);
}
.table-container {
max-height: 500px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
border-radius: 0.5rem;
}
.table-container::-webkit-scrollbar {
width: 6px;
}
.table-container::-webkit-scrollbar-track {
background: transparent;
}
.table-container::-webkit-scrollbar-thumb {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 3px;
}
.badge {
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
display: inline-flex;
align-items: center;
gap: 0.25rem;
}
.badge-sandbox {
background-color: rgba(245, 158, 11, 0.2);
color: #f59e0b;
}
.badge-formal {
background-color: rgba(16, 185, 129, 0.2);
color: #10b981;
}
.badge-temp {
background-color: rgba(99, 102, 241, 0.2);
color: #6366f1;
}
.badge-permanent {
background-color: rgba(139, 92, 246, 0.2);
color: #8b5cf6;
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.progress-bar {
height: 8px;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
overflow: hidden;
margin-top: 0.5rem;
}
.progress-bar-fill {
height: 100%;
background: linear-gradient(90deg, #3b82f6, #60a5fa);
transition: width 0.3s ease;
}
.progress-bar-fill.warning {
background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.progress-bar-fill.danger {
background: linear-gradient(90deg, #ef4444, #f87171);
}
.stat-value {
font-size: 2.5rem;
font-weight: 700;
line-height: 1;
margin: 0.5rem 0;
}
.stat-label {
font-size: 0.875rem;
color: rgba(255, 255, 255, 0.6);
margin-top: 0.25rem;
}
.table-header {
position: sticky;
top: 0;
background: rgba(17, 24, 39, 0.95);
backdrop-filter: blur(8px);
z-index: 10;
}
.table-row {
transition: all 0.2s ease;
}
.table-row:hover {
background: rgba(255, 255, 255, 0.05);
}
</style>
</head>
<body class="gradient-bg text-white">
<div class="container mx-auto px-4 py-8">
<!-- 标题 -->
<div class="flex items-center justify-center mb-8">
<div class="text-center">
<i class="fas fa-chart-line text-5xl mb-4 text-blue-400"></i>
<h1 class="text-4xl font-bold">连接统计</h1>
<p class="text-gray-400 mt-2">实时监控系统状态和连接信息</p>
</div>
</div>
<!-- 统计卡片 -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="stat-card card p-6">
<div class="flex items-center mb-4">
<i class="fas fa-plug text-2xl mr-3 text-blue-400"></i>
<h3 class="text-lg font-semibold">在线连接</h3>
</div>
<div class="stat-value" id="online-count">0</div>
<div class="stat-label">当前活跃连接数</div>
</div>
<div class="stat-card card p-6">
<div class="flex items-center mb-4">
<i class="fas fa-history text-2xl mr-3 text-purple-400"></i>
<h3 class="text-lg font-semibold">历史连接</h3>
</div>
<div class="stat-value" id="history-count">0</div>
<div class="stat-label">累计连接次数</div>
</div>
<div class="stat-card card p-6">
<div class="flex items-center mb-4">
<i class="fas fa-exchange-alt text-2xl mr-3 text-green-400"></i>
<h3 class="text-lg font-semibold">Webhook转发</h3>
</div>
<div class="stat-value" id="webhook-count">0</div>
<div class="stat-label">
<div class="flex items-center justify-between">
<span>总转发数</span>
<span id="webhook-bytes" class="text-gray-400">0 B</span>
</div>
</div>
</div>
<div class="stat-card card p-6">
<div class="flex items-center mb-4">
<i class="fas fa-key text-2xl mr-3 text-yellow-400"></i>
<h3 class="text-lg font-semibold">活跃密钥</h3>
</div>
<div class="stat-value" id="active-keys">0</div>
<div class="stat-label">当前活跃密钥数</div>
</div>
</div>
<!-- 系统资源监控 -->
<div class="card p-6 mb-8">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold flex items-center">
<i class="fas fa-microchip mr-3 text-blue-400"></i>
系统资源
</h2>
<span class="text-sm text-gray-400">实时更新</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
<!-- CPU使用率 -->
<div>
<div class="flex justify-between items-center mb-2">
<span class="text-sm font-medium">CPU使用率</span>
<span class="text-sm font-medium" id="cpu-percent">0%</span>
</div>
<div class="progress-bar">
<div class="progress-bar-fill" id="cpu-bar" style="width: 0%"></div>
</div>
</div>
<!-- 内存使用率 -->
<div>
<div class="flex justify-between items-center mb-2">
<span class="text-sm font-medium">内存使用率</span>
<span class="text-sm font-medium" id="memory-percent">0%</span>
</div>
<div class="progress-bar">
<div class="progress-bar-fill" id="memory-bar" style="width: 0%"></div>
</div>
</div>
<!-- CPU核心数 -->
<div>
<span class="text-sm text-gray-400">CPU核心数</span>
<p id="cpu-count" class="mt-1 font-medium"></p>
</div>
<!-- 内存使用详情 -->
<div>
<span class="text-sm text-gray-400">内存使用</span>
<p id="memory-usage" class="mt-1 font-medium"></p>
</div>
</div>
</div>
<!-- 在线连接 -->
<div class="card p-6 mb-8">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold flex items-center">
<i class="fas fa-users mr-3 text-blue-400"></i>
在线连接
</h2>
<span class="text-sm text-gray-400">实时更新</span>
</div>
<div class="table-container">
<table class="w-full">
<thead class="table-header">
<tr class="text-left">
<th class="py-4 px-4">密钥</th>
<th class="py-4 px-4">Token</th>
<th class="py-4 px-4">环境</th>
<th class="py-4 px-4">类型</th>
</tr>
</thead>
<tbody id="online-connections">
</tbody>
</table>
</div>
</div>
<!-- Webhook转发 -->
<div class="card p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold flex items-center">
<i class="fas fa-broadcast-tower mr-3 text-green-400"></i>
Webhook转发
</h2>
<div class="flex items-center space-x-4">
<div class="text-sm text-gray-400">
<i class="fas fa-database mr-1"></i>
总数据量: <span id="total-webhook-bytes" class="font-medium">0 B</span>
</div>
<span class="text-sm text-gray-400">实时更新</span>
</div>
</div>
<div class="table-container">
<table class="w-full">
<thead class="table-header">
<tr class="text-left">
<th class="py-4 px-4">密钥</th>
<th class="py-4 px-4">转发地址</th>
<th class="py-4 px-4">转发数</th>
<th class="py-4 px-4">数据量</th>
</tr>
</thead>
<tbody id="webhook-forwards">
</tbody>
</table>
</div>
</div>
</div>
<script>
function formatBytes(bytes) {
if (bytes === 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
function updateProgressBar(element, value, warning = 70, danger = 90) {
element.style.width = value + '%';
element.className = 'progress-bar-fill';
if (value >= danger) {
element.classList.add('danger');
} else if (value >= warning) {
element.classList.add('warning');
}
}
function updateStats() {
fetch('/api/stats')
.then(response => response.json())
.then(data => {
// 更新统计数字
document.getElementById('online-count').textContent = data.online_count;
document.getElementById('history-count').textContent = data.history_count;
document.getElementById('webhook-count').textContent = data.webhook_count;
document.getElementById('webhook-bytes').textContent = formatBytes(data.webhook_total_bytes);
document.getElementById('total-webhook-bytes').textContent = formatBytes(data.webhook_total_bytes);
document.getElementById('active-keys').textContent = data.active_keys;
// 更新在线连接表格
const onlineTable = document.getElementById('online-connections');
const allConnections = [
...(data.online_connections || []).map(conn => ({...conn, is_online: true})),
...(data.offline_connections || []).map(conn => ({...conn, is_online: false}))
];
onlineTable.innerHTML = allConnections.map(conn => `
<tr class="table-row border-t border-gray-700 fade-in">
<td class="py-3 px-4">
<div class="flex items-center">
${conn.is_online ?
'<span class="badge bg-success mr-2">在线</span>' :
'<span class="badge bg-secondary mr-2">离线</span>'}
${conn.secret}
</div>
</td>
<td class="py-3 px-4">${conn.token || '<span class="text-gray-500">无</span>'}</td>
<td class="py-3 px-4">
<span class="badge ${conn.environment === '沙盒环境' ? 'badge-sandbox' : 'badge-formal'}">
<i class="fas ${conn.environment === '沙盒环境' ? 'fa-flask' : 'fa-check-circle'}"></i>
${conn.environment}
</span>
</td>
<td class="py-3 px-4">
<span class="badge ${conn.type === '临时连接' ? 'badge-temp' : 'badge-permanent'}">
<i class="fas ${conn.type === '临时连接' ? 'fa-clock' : 'fa-link'}"></i>
${conn.type}
</span>
</td>
</tr>
`).join('');
// 更新系统资源信息
const systemStats = data.system_stats;
document.getElementById('cpu-percent').textContent = systemStats.cpu_percent + '%';
document.getElementById('memory-percent').textContent = systemStats.memory_percent + '%';
updateProgressBar(document.getElementById('cpu-bar'), systemStats.cpu_percent);
updateProgressBar(document.getElementById('memory-bar'), systemStats.memory_percent);
// 更新系统信息
document.getElementById('cpu-count').textContent = systemStats.system_info.cpu_count + ' 核心';
const usedMemory = systemStats.system_info.total_memory * (systemStats.memory_percent / 100);
document.getElementById('memory-usage').textContent =
`${formatBytes(usedMemory)} / ${formatBytes(systemStats.system_info.total_memory)}`;
// 更新Webhook转发表格
const webhookTable = document.getElementById('webhook-forwards');
webhookTable.innerHTML = data.webhook_forwards.map(forward => `
<tr class="table-row border-t border-gray-700 fade-in">
<td class="py-3 px-4">${forward.secret}</td>
<td class="py-3 px-4">
<div class="flex items-center">
<i class="fas fa-link text-gray-400 mr-2"></i>
${forward.url}
</div>
</td>
<td class="py-3 px-4">
<span class="badge badge-formal">
<i class="fas fa-exchange-alt"></i>
${forward.count}
</span>
</td>
<td class="py-3 px-4">
<span class="text-sm text-gray-400">
<i class="fas fa-database mr-1"></i>
${formatBytes(forward.total_bytes)}
</span>
</td>
</tr>
`).join('');
})
.catch(error => console.error('Error:', error));
}
// 每5秒更新一次数据
setInterval(updateStats, 5000);
updateStats();
</script>
</body>
</html>