feat: 实时监控频率可调节
This commit is contained in:
26
app.py
26
app.py
@@ -1040,7 +1040,7 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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">
|
||||||
<title>项目服务管理面板 v2.6</title>
|
<title>项目服务管理面板 v2.7</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📊</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📊</text></svg>">
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
|
||||||
@@ -1302,7 +1302,14 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|||||||
<div class="realtime-toggle" id="realtimeToggle">
|
<div class="realtime-toggle" id="realtimeToggle">
|
||||||
<input type="checkbox" id="realtimeCheck" onchange="toggleRealtime()" class="w-4 h-4 cursor-pointer">
|
<input type="checkbox" id="realtimeCheck" onchange="toggleRealtime()" class="w-4 h-4 cursor-pointer">
|
||||||
<label for="realtimeCheck" class="text-gray-300 text-sm cursor-pointer">实时监控</label>
|
<label for="realtimeCheck" class="text-gray-300 text-sm cursor-pointer">实时监控</label>
|
||||||
<span id="realtimeIndicator" class="text-xs text-gray-500 ml-1"></span>
|
<select id="realtimeIntervalSelect" class="bg-gray-700 text-gray-200 px-2 py-1 rounded text-xs ml-2 cursor-pointer" onchange="updateRealtimeInterval()">
|
||||||
|
<option value="1">1秒</option>
|
||||||
|
<option value="2" selected>2秒</option>
|
||||||
|
<option value="3">3秒</option>
|
||||||
|
<option value="5">5秒</option>
|
||||||
|
<option value="10">10秒</option>
|
||||||
|
</select>
|
||||||
|
<span id="realtimeIndicator" class="text-xs text-green-400 ml-1 hidden">●</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1578,7 +1585,7 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|||||||
realtimeTimer = null;
|
realtimeTimer = null;
|
||||||
document.getElementById('realtimeCheck').checked = false;
|
document.getElementById('realtimeCheck').checked = false;
|
||||||
document.getElementById('realtimeToggle').classList.remove('active');
|
document.getElementById('realtimeToggle').classList.remove('active');
|
||||||
document.getElementById('realtimeIndicator').textContent = '';
|
document.getElementById('realtimeIndicator').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab === 'cron') {
|
if (tab === 'cron') {
|
||||||
@@ -1593,6 +1600,15 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|||||||
let realtimeTimer = null;
|
let realtimeTimer = null;
|
||||||
let realtimeInterval = 2; // 秒
|
let realtimeInterval = 2; // 秒
|
||||||
|
|
||||||
|
function updateRealtimeInterval() {
|
||||||
|
realtimeInterval = parseInt(document.getElementById('realtimeIntervalSelect').value) || 2;
|
||||||
|
// 如果正在监控,重新启动定时器
|
||||||
|
if (realtimeTimer) {
|
||||||
|
clearInterval(realtimeTimer);
|
||||||
|
realtimeTimer = setInterval(loadSystemStats, realtimeInterval * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadSystemStats() {
|
async function loadSystemStats() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/system/stats');
|
const res = await fetch('/api/system/stats');
|
||||||
@@ -1649,14 +1665,14 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
|||||||
|
|
||||||
if (checked) {
|
if (checked) {
|
||||||
toggle.classList.add('active');
|
toggle.classList.add('active');
|
||||||
indicator.textContent = '每' + realtimeInterval + '秒';
|
indicator.classList.remove('hidden');
|
||||||
// 立即加载一次
|
// 立即加载一次
|
||||||
loadSystemStats();
|
loadSystemStats();
|
||||||
// 启动定时器
|
// 启动定时器
|
||||||
realtimeTimer = setInterval(loadSystemStats, realtimeInterval * 1000);
|
realtimeTimer = setInterval(loadSystemStats, realtimeInterval * 1000);
|
||||||
} else {
|
} else {
|
||||||
toggle.classList.remove('active');
|
toggle.classList.remove('active');
|
||||||
indicator.textContent = '';
|
indicator.classList.add('hidden');
|
||||||
// 停止定时器
|
// 停止定时器
|
||||||
if (realtimeTimer) {
|
if (realtimeTimer) {
|
||||||
clearInterval(realtimeTimer);
|
clearInterval(realtimeTimer);
|
||||||
|
|||||||
45
logs/app.log
45
logs/app.log
@@ -1,8 +1,8 @@
|
|||||||
[2026-04-23 17:27:44] ==================================================
|
[2026-04-23 17:35:41] ==================================================
|
||||||
[2026-04-23 17:27:44] 项目服务管理面板 v2.0.0 启动
|
[2026-04-23 17:35:41] 项目服务管理面板 v2.0.0 启动
|
||||||
[2026-04-23 17:27:44] 访问地址: http://localhost:19013
|
[2026-04-23 17:35:41] 访问地址: http://localhost:19013
|
||||||
[2026-04-23 17:27:44] 进程PID: 1130035
|
[2026-04-23 17:35:41] 进程PID: 1133475
|
||||||
[2026-04-23 17:27:44] ==================================================
|
[2026-04-23 17:35:41] ==================================================
|
||||||
* Serving Flask app 'app'
|
* Serving Flask app 'app'
|
||||||
* Debug mode: off
|
* Debug mode: off
|
||||||
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
|
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
|
||||||
@@ -10,33 +10,8 @@ WARNING: This is a development server. Do not use it in a production deployment.
|
|||||||
* Running on http://127.0.0.1:19013
|
* Running on http://127.0.0.1:19013
|
||||||
* Running on http://192.168.2.17:19013
|
* Running on http://192.168.2.17:19013
|
||||||
Press CTRL+C to quit
|
Press CTRL+C to quit
|
||||||
127.0.0.1 - - [23/Apr/2026 17:27:49] "GET /api/system/stats HTTP/1.1" 200 -
|
127.0.0.1 - - [23/Apr/2026 17:35:43] "GET / HTTP/1.1" 200 -
|
||||||
127.0.0.1 - - [23/Apr/2026 17:27:51] "GET / HTTP/1.1" 200 -
|
127.0.0.1 - - [23/Apr/2026 17:35:44] "GET / HTTP/1.1" 200 -
|
||||||
127.0.0.1 - - [23/Apr/2026 17:27:52] "GET / HTTP/1.1" 200 -
|
192.168.2.8 - - [23/Apr/2026 17:35:45] "GET /api/projects HTTP/1.1" 200 -
|
||||||
192.168.2.14 - - [23/Apr/2026 17:27:53] "GET /api/projects HTTP/1.1" 200 -
|
127.0.0.1 - - [23/Apr/2026 17:35:53] "GET / HTTP/1.1" 200 -
|
||||||
192.168.2.8 - - [23/Apr/2026 17:27:54] "GET /api/projects HTTP/1.1" 200 -
|
192.168.2.8 - - [23/Apr/2026 17:35:55] "GET /api/projects HTTP/1.1" 200 -
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:02] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:02] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.14 - - [23/Apr/2026 17:28:03] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:04] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:10] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:12] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:12] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:12] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.14 - - [23/Apr/2026 17:28:13] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:14] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:21] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:22] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.14 - - [23/Apr/2026 17:28:23] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:24] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:31] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:32] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:33] "GET /api/system/stats HTTP/1.1" 200 -
|
|
||||||
192.168.2.14 - - [23/Apr/2026 17:28:33] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:34] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:40] "GET / HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:41] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:42] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
127.0.0.1 - - [23/Apr/2026 17:28:43] "GET / HTTP/1.1" 200 -
|
|
||||||
192.168.2.14 - - [23/Apr/2026 17:28:43] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
192.168.2.8 - - [23/Apr/2026 17:28:44] "GET /api/projects HTTP/1.1" 200 -
|
|
||||||
|
|||||||
Reference in New Issue
Block a user