Files
task-board/public/status.html
T

129 lines
3.7 KiB
HTML
Raw Normal View History

<!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>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
background: #f5f5f5;
}
.status-card {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.status-ok { color: #4caf50; }
.status-error { color: #f44336; }
h1 { color: #667eea; }
.info { margin: 10px 0; padding: 10px; background: #f9f9f9; border-radius: 5px; }
button {
padding: 10px 20px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover { opacity: 0.9; }
#log { font-family: monospace; font-size: 12px; white-space: pre-wrap; }
</style>
</head>
<body>
<div class="status-card">
<h1>🚀 系统状态检查</h1>
<div class="info">
<strong>服务器:</strong> <span id="server-status" class="status-ok">✅ 运行中</span><br>
<strong>时间:</strong> <span id="current-time"></span><br>
<strong>浏览器:</strong> <span id="browser"></span>
</div>
<h3>功能测试</h3>
<button onclick="testAPI()">测试 API</button>
<button onclick="testProjects()">测试项目列表</button>
<button onclick="testRules()">测试规约</button>
<button onclick="clearCache()">清除缓存</button>
<button onclick="location.href='/'">返回主页</button>
<div id="log" class="info" style="margin-top: 20px; max-height: 300px; overflow-y: auto;">
等待测试...
</div>
</div>
<script>
const log = (msg, isError = false) => {
const logDiv = document.getElementById('log');
const time = new Date().toLocaleTimeString();
const prefix = isError ? '❌' : '✅';
logDiv.innerHTML += `\n${time} ${prefix} ${msg}`;
logDiv.scrollTop = logDiv.scrollHeight;
};
document.getElementById('current-time').textContent = new Date().toLocaleString('zh-CN');
document.getElementById('browser').textContent = navigator.userAgent.split(' ').pop();
async function testAPI() {
log('测试 /api/stats ...');
try {
const res = await fetch('/api/stats');
const data = await res.json();
log(`API 正常 - 项目:${data.projects} 任务:${data.tasks}`);
} catch (e) {
log('API 错误: ' + e.message, true);
}
}
async function testProjects() {
log('测试 /api/projects ...');
try {
const res = await fetch('/api/projects');
const data = await res.json();
log(`获取到 ${data.length} 个项目`);
data.forEach(p => log(` - ${p.name}`));
} catch (e) {
log('项目列表错误: ' + e.message, true);
}
}
async function testRules() {
log('测试 /api/rules/global ...');
try {
const res = await fetch('/api/rules/global');
const data = await res.json();
log(`获取到 ${data.length} 条全局规约`);
} catch (e) {
log('规约错误: ' + e.message, true);
}
}
function clearCache() {
log('清除缓存...');
if ('caches' in window) {
caches.keys().then(names => {
names.forEach(name => caches.delete(name));
});
}
localStorage.clear();
sessionStorage.clear();
log('缓存已清除,请刷新页面');
}
// 自动运行基础测试
window.addEventListener('load', () => {
setTimeout(() => {
log('=== 自动测试开始 ===');
testAPI();
}, 500);
});
</script>
</body>
</html>