zai / app /templates /request_logs.html
bg5's picture
Upload 85 files
e0b68d2 verified
Raw History Blame Contribute Delete
3.91 kB
{% extends "base.html" %}
{% block title %}请求日志{% endblock %}
{% block content %}
<div class="flex-1 flex flex-col min-h-0 space-y-6">
<div class="flex items-center justify-between flex-shrink-0">
<div>
<h2 class="text-3xl font-bold text-gray-900">请求日志</h2>
<p class="mt-1 text-sm text-gray-600">查看历史 API 调用请求记录</p>
</div>
<div class="flex items-center space-x-3">
<!-- 自动刷新 Toggle -->
<label
class="flex items-center space-x-2 cursor-pointer bg-gray-50 px-3 py-1.5 rounded border border-gray-200 hover:bg-gray-100 transition-colors">
<input type="checkbox" id="recent-logs-auto-refresh"
class="form-checkbox h-4 w-4 text-slate-800 transition duration-150 ease-in-out" checked>
<span class="text-sm text-gray-700 select-none">自动刷新</span>
</label>
<!-- 刷新按钮 -->
<button onclick="loadRecentLogsPage(window.dashboardRecentLogsPage || 1)"
class="px-3 py-1.5 bg-slate-800 text-white text-sm rounded hover:bg-slate-700 transition-colors flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15">
</path>
</svg>
刷新
</button>
</div>
</div>
<div class="bg-white shadow rounded-lg flex-1 flex flex-col min-h-0 overflow-hidden">
<div class="px-6 py-4 border-b border-gray-200 flex-shrink-0">
<h3 class="text-lg font-medium text-gray-900">日志详情</h3>
</div>
<div class="p-6 flex-1 flex flex-col min-h-0 overflow-hidden">
<div id="recent-logs" class="flex-1 flex flex-col min-h-0"
hx-get="{{ root_path }}/admin/api/recent-logs?page=1&page_size=15" hx-trigger="load" hx-swap="innerHTML">
<div class="flex justify-center items-center py-12">
<svg class="animate-spin h-8 w-8 text-indigo-600" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4">
</circle>
<path class="opacity-75" fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
</path>
</svg>
<span class="ml-3 text-gray-500">加载中...</span>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block extra_scripts %}
<script>
const RECENT_LOGS_PAGE_SIZE = 15;
window.dashboardRecentLogsPage = 1;
window.dashboardRecentLogsPageSize = RECENT_LOGS_PAGE_SIZE;
function loadRecentLogsPage(page) {
const nextPage = Math.max(1, Number(page) || 1);
window.dashboardRecentLogsPage = nextPage;
const url = window.adminPath(`/admin/api/recent-logs?page=${nextPage}&page_size=${window.dashboardRecentLogsPageSize}`);
htmx.ajax('GET', url, {
target: '#recent-logs',
swap: 'innerHTML'
});
}
setInterval(() => {
const checkbox = document.getElementById('recent-logs-auto-refresh');
if (checkbox && checkbox.checked) {
loadRecentLogsPage(window.dashboardRecentLogsPage || 1);
}
}, 3000);
</script>
{% endblock %}