Files
llm-proxy/templates/logs.html

98 lines
4.2 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>日志查看 - LLM Proxy</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
<style>
.gradient-bg { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.log-line { font-family: monospace; font-size: 12px; }
.log-info { color: #2563eb; }
.log-warning { color: #d97706; }
.log-error { color: #dc2626; }
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="flex">
<aside class="w-64 bg-slate-800 min-h-screen fixed left-0 top-0">
<div class="p-6">
<h1 class="text-white text-xl font-bold flex items-center gap-2">
<i class="ri-route-line text-2xl text-purple-400"></i>
LLM Proxy
</h1>
<p class="text-slate-400 text-sm mt-1">后台管理</p>
</div>
<nav class="mt-6">
<a href="/admin" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-dashboard-line"></i><span>仪表盘</span>
</a>
<a href="/admin/providers" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-server-line"></i><span>提供商管理</span>
</a>
<a href="/admin/models" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-cpu-line"></i><span>模型管理</span>
</a>
<a href="/admin/logs" class="flex items-center gap-3 px-6 py-3 bg-slate-700 text-white">
<i class="ri-file-list-line"></i><span>日志查看</span>
</a>
<a href="/admin/config" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-settings-3-line"></i><span>系统配置</span>
</a>
</nav>
</aside>
<main class="ml-64 flex-1 p-8">
<div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold text-gray-800">日志查看</h1>
<button onclick="loadLogs()" class="px-4 py-2 border border-gray-300 rounded-lg text-sm hover:bg-gray-50">
<i class="ri-refresh-line mr-1"></i> 刷新
</button>
</div>
<div class="bg-white rounded-xl border border-gray-100 p-4">
<div id="logContent" class="bg-gray-900 rounded-lg p-4 max-h-[600px] overflow-auto">
<p class="text-gray-500">加载中...</p>
</div>
</div>
</main>
</div>
<script>
async function loadLogs() {
const res = await fetch('/api/admin/logs');
const data = await res.json();
const container = document.getElementById('logContent');
if (data.logs.length === 0) {
container.innerHTML = '<p class="text-gray-400">暂无日志</p>';
return;
}
container.innerHTML = data.logs.map(line => {
let cls = 'text-gray-300';
if (line.includes('ERROR') || line.includes('error')) cls = 'log-error';
else if (line.includes('WARNING') || line.includes('warning')) cls = 'log-warning';
else if (line.includes('INFO')) cls = 'log-info';
return `<div class="log-line ${cls}">${escapeHtml(line)}</div>`;
}).join('');
}
function escapeHtml(text) {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
loadLogs();
// 自动刷新
setInterval(loadLogs, 10000);
</script>
</body>
</html>