初始提交: LiteAdmin 社区平台
This commit is contained in:
@@ -0,0 +1,545 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}LiteAdmin 管理后台{% endblock %}</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary: #2563eb;
|
||||
--primary-dark: #1d4ed8;
|
||||
--primary-light: #dbeafe;
|
||||
--sidebar-bg: #1e293b;
|
||||
--sidebar-text: #94a3b8;
|
||||
--sidebar-active: #2563eb;
|
||||
--bg: #f1f5f9;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1e293b;
|
||||
--text-light: #64748b;
|
||||
--border: #e2e8f0;
|
||||
--success: #22c55e;
|
||||
--warning: #f59e0b;
|
||||
--danger: #ef4444;
|
||||
--info: #3b82f6;
|
||||
--radius: 8px;
|
||||
--shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
|
||||
--shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 10px 15px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
a { color: var(--primary); text-decoration: none; }
|
||||
a:hover { color: var(--primary-dark); text-decoration: underline; }
|
||||
|
||||
/* 侧边栏 */
|
||||
.sidebar {
|
||||
width: 240px;
|
||||
background: var(--sidebar-bg);
|
||||
color: var(--sidebar-text);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100vh;
|
||||
z-index: 100;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.sidebar-header h1 {
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar-header .subtitle {
|
||||
font-size: 12px;
|
||||
color: var(--sidebar-text);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.sidebar-nav { padding: 12px 0; flex: 1; }
|
||||
|
||||
.nav-section { margin-bottom: 8px; }
|
||||
|
||||
.nav-section-title {
|
||||
padding: 8px 20px 4px;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #475569;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 20px;
|
||||
color: var(--sidebar-text);
|
||||
transition: all 0.15s;
|
||||
cursor: pointer;
|
||||
border-left: 3px solid transparent;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: rgba(255,255,255,0.05);
|
||||
color: #e2e8f0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
background: rgba(37,99,235,0.15);
|
||||
color: #60a5fa;
|
||||
border-left-color: var(--sidebar-active);
|
||||
}
|
||||
|
||||
.nav-item .icon {
|
||||
margin-right: 10px;
|
||||
font-size: 16px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 16px 20px;
|
||||
border-top: 1px solid rgba(255,255,255,0.06);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.sidebar-footer .user-info {
|
||||
color: #e2e8f0;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* 主区域 */
|
||||
.main {
|
||||
margin-left: 240px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
background: var(--card-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 12px 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.topbar .breadcrumb {
|
||||
font-size: 14px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.topbar .breadcrumb a { color: var(--text-light); }
|
||||
.topbar .breadcrumb span { color: var(--text); font-weight: 500; }
|
||||
|
||||
.topbar-right { display: flex; align-items: center; gap: 16px; }
|
||||
|
||||
.content {
|
||||
padding: 24px 28px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 页面标题 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-header h2 {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* 卡片 */
|
||||
.card {
|
||||
background: var(--card-bg);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--border);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.card-header h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.card-body { padding: 20px; }
|
||||
|
||||
/* 按钮 */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--card-bg);
|
||||
color: var(--text);
|
||||
transition: all 0.15s;
|
||||
text-decoration: none;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.btn:hover { text-decoration: none; }
|
||||
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
|
||||
.btn-primary:hover { background: var(--primary-dark); }
|
||||
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
|
||||
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
|
||||
.btn-sm { padding: 5px 10px; font-size: 13px; }
|
||||
.btn-danger:hover { background: #dc2626; }
|
||||
|
||||
/* 表单 */
|
||||
.form-group { margin-bottom: 16px; }
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
background: var(--card-bg);
|
||||
transition: border-color 0.15s;
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
|
||||
select.form-control { cursor: pointer; }
|
||||
textarea.form-control { min-height: 100px; resize: vertical; }
|
||||
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
|
||||
|
||||
/* 表格 */
|
||||
.table-wrap { overflow-x: auto; }
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table th, table td {
|
||||
padding: 10px 14px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
table th {
|
||||
background: #f8fafc;
|
||||
font-weight: 600;
|
||||
color: var(--text-light);
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
table tr:hover td { background: #f8fafc; }
|
||||
table tr:last-child td { border-bottom: none; }
|
||||
|
||||
/* 搜索框 */
|
||||
.search-box {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.search-box input { flex: 1; max-width: 320px; }
|
||||
|
||||
/* 分页 */
|
||||
.pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.pagination a, .pagination span {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); }
|
||||
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
|
||||
.pagination .disabled { color: var(--text-light); cursor: not-allowed; }
|
||||
|
||||
/* 标签 / Badge */
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.badge-success { background: #dcfce7; color: #166534; }
|
||||
.badge-warning { background: #fef3c7; color: #92400e; }
|
||||
.badge-danger { background: #fce4ec; color: #c62828; }
|
||||
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
|
||||
|
||||
/* 统计卡片 */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--card-bg);
|
||||
border-radius: var(--radius);
|
||||
border: 1px solid var(--border);
|
||||
padding: 20px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.stat-card .stat-label {
|
||||
font-size: 13px;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.stat-card .stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.stat-card .stat-icon {
|
||||
float: right;
|
||||
font-size: 32px;
|
||||
opacity: 0.15;
|
||||
}
|
||||
|
||||
/* Toast 消息 */
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.toast {
|
||||
padding: 12px 20px;
|
||||
border-radius: 6px;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
margin-bottom: 8px;
|
||||
box-shadow: var(--shadow-lg);
|
||||
animation: slideIn 0.25s ease;
|
||||
}
|
||||
|
||||
.toast-success { background: var(--success); }
|
||||
.toast-error { background: var(--danger); }
|
||||
.toast-info { background: var(--info); }
|
||||
.toast-warning { background: var(--warning); }
|
||||
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(100%); opacity: 0; }
|
||||
to { transform: translateX(0); opacity: 1; }
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
|
||||
|
||||
/* 确认对话框 */
|
||||
.modal-overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 1000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal-overlay.active { display: flex; }
|
||||
|
||||
.modal {
|
||||
background: var(--card-bg);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
max-width: 400px;
|
||||
width: 90%;
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.modal h3 { margin-bottom: 12px; }
|
||||
.modal .actions { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }
|
||||
|
||||
/* 文件管理 */
|
||||
.file-list .file-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.file-list .file-item:last-child { border-bottom: none; }
|
||||
.file-list .file-item .name { flex: 1; }
|
||||
.file-list .file-item .size { color: var(--text-light); font-size: 13px; margin-right: 12px; }
|
||||
.file-list .file-item .date { color: var(--text-light); font-size: 13px; margin-right: 12px; }
|
||||
|
||||
/* 日志查看器 */
|
||||
.log-viewer {
|
||||
background: #1e293b;
|
||||
color: #e2e8f0;
|
||||
border-radius: var(--radius);
|
||||
padding: 16px;
|
||||
font-family: "SF Mono", "Fira Code", "Consolas", monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.log-entry { padding: 2px 0; white-space: pre-wrap; word-break: break-all; }
|
||||
.log-DEBUG { color: #94a3b8; }
|
||||
.log-INFO { color: #60a5fa; }
|
||||
.log-WARNING { color: #fbbf24; }
|
||||
.log-ERROR { color: #f87171; }
|
||||
.log-CRITICAL { color: #ef4444; font-weight: bold; }
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar { width: 60px; }
|
||||
.sidebar-header h1, .sidebar-header .subtitle,
|
||||
.nav-item span, .nav-section-title, .sidebar-footer { display: none; }
|
||||
.main { margin-left: 60px; }
|
||||
.content { padding: 16px; }
|
||||
.stats-grid { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h1>LiteAdmin</h1>
|
||||
<div class="subtitle">管理后台</div>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<div class="nav-section">
|
||||
<div class="nav-section-title">概览</div>
|
||||
<a href="/admin/" class="nav-item {% if request.path == '/admin/' %}active{% endif %}">
|
||||
<span class="icon">☗</span><span>控制台</span>
|
||||
</a>
|
||||
</div>
|
||||
{% if admin_models %}
|
||||
<div class="nav-section">
|
||||
<div class="nav-section-title">数据管理</div>
|
||||
{% for model_name, model_info in admin_models.items() %}
|
||||
<a href="/admin/{{ model_name }}/" class="nav-item {% if request.path.startswith('/admin/' + model_name) %}active{% endif %}">
|
||||
<span class="icon">☰</span><span>{{ model_info.verbose_name or model_name }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="nav-section">
|
||||
<div class="nav-section-title">系统</div>
|
||||
<a href="/admin/logs/" class="nav-item {% if request.path == '/admin/logs/' %}active{% endif %}">
|
||||
<span class="icon">⚙</span><span>运行日志</span>
|
||||
</a>
|
||||
<a href="/admin/files/" class="nav-item {% if request.path == '/admin/files/' %}active{% endif %}">
|
||||
<span class="icon">📁</span><span>文件管理</span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="user-info">{{ current_user.username }}</div>
|
||||
<a href="/admin/logout/" style="color: var(--danger); font-size: 13px;">退出登录</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主区域 -->
|
||||
<div class="main">
|
||||
<div class="topbar">
|
||||
<div class="breadcrumb">
|
||||
{% block breadcrumb %}
|
||||
<a href="/admin/">控制台</a>
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class="topbar-right">
|
||||
<span style="font-size:13px;color:var(--text-light);">{{ current_user.username }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
{% if flash_message %}
|
||||
<div class="toast-container">
|
||||
<div class="toast toast-{{ flash_type or 'info' }}">{{ flash_message }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Toast 自动消失
|
||||
var toasts = document.querySelectorAll('.toast');
|
||||
toasts.forEach(function(t) {
|
||||
setTimeout(function() { t.style.opacity = '0'; t.style.transition = 'opacity 0.3s'; }, 3000);
|
||||
setTimeout(function() { t.remove(); }, 3300);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}控制台 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<span>控制台</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>控制台</h2>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
{% for stat in stats %}
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">{{ stat.icon }}</div>
|
||||
<div class="stat-label">{{ stat.label }}</div>
|
||||
<div class="stat-value">{{ stat.value }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if recent_items %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>最近更新</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>模型</th>
|
||||
<th>ID</th>
|
||||
<th>标题</th>
|
||||
<th>更新时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in recent_items %}
|
||||
<tr>
|
||||
<td><span class="badge badge-info">{{ item.model_verbose }}</span></td>
|
||||
<td>{{ item.id }}</td>
|
||||
<td><a href="/admin/{{ item.model_name }}/{{ item.id }}/">{{ item.title }}</a></td>
|
||||
<td>{{ item.updated_at }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>系统信息</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr><td style="width:200px;font-weight:500;">LiteAdmin 版本</td><td>v1.0.0</td></tr>
|
||||
<tr><td style="font-weight:500;">Python 版本</td><td>{{ system_info.python_version }}</td></tr>
|
||||
<tr><td style="font-weight:500;">数据库</td><td>SQLite</td></tr>
|
||||
<tr><td style="font-weight:500;">数据目录</td><td>{{ system_info.db_path }}</td></tr>
|
||||
<tr><td style="font-weight:500;">上传目录</td><td>{{ system_info.upload_dir }}</td></tr>
|
||||
<tr><td style="font-weight:500;">运行时间</td><td>{{ system_info.uptime }}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,54 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}文件管理 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <span>文件管理</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>文件管理</h2>
|
||||
<div>
|
||||
<form method="post" enctype="multipart/form-data" style="display:flex;gap:8px;align-items:center;">
|
||||
<input type="file" name="file" class="form-control" style="width:auto;" required>
|
||||
<button type="submit" class="btn btn-primary btn-sm">上传</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>当前目录: {{ current_path or '/' }}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if files %}
|
||||
<div class="file-list">
|
||||
{% if parent_path %}
|
||||
<div class="file-item">
|
||||
<span class="icon" style="margin-right:10px;">📁</span>
|
||||
<span class="name"><a href="/admin/files/?path={{ parent_path }}">..</a></span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for file in files %}
|
||||
<div class="file-item">
|
||||
<span class="icon" style="margin-right:10px;">{% if file.is_dir %}📁{% else %}📄{% endif %}</span>
|
||||
<span class="name">
|
||||
{% if file.is_dir %}
|
||||
<a href="/admin/files/?path={{ file.path }}">{{ file.name }}</a>
|
||||
{% else %}
|
||||
<a href="/admin/files/download/?path={{ file.path }}" target="_blank">{{ file.name }}</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if not file.is_dir %}
|
||||
<span class="size">{{ file.size }}</span>
|
||||
{% endif %}
|
||||
<span class="date">{{ file.modified }}</span>
|
||||
<a href="/admin/files/delete/?path={{ file.path }}" class="btn btn-sm btn-danger" onclick="return confirm('确定删除 {{ file.name }} 吗?')">删除</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="icon">📁</div>
|
||||
<p>此目录为空</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>登录 - LiteAdmin</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary: #2563eb;
|
||||
--primary-dark: #1d4ed8;
|
||||
--bg: #f1f5f9;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1e293b;
|
||||
--text-light: #64748b;
|
||||
--border: #e2e8f0;
|
||||
--radius: 8px;
|
||||
--shadow: 0 4px 6px rgba(0,0,0,0.07), 0 10px 15px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-wrapper {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: var(--card-bg);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.login-card h1 {
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.login-card .subtitle {
|
||||
text-align: center;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 28px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 6px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
transition: border-color 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 10px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.btn:hover { background: var(--primary-dark); }
|
||||
|
||||
.error-msg {
|
||||
background: #fce4ec;
|
||||
color: #c62828;
|
||||
padding: 10px 14px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: rgba(255,255,255,0.6);
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-wrapper">
|
||||
<div class="login-card">
|
||||
<h1>LiteAdmin</h1>
|
||||
<div class="subtitle">管理后台登录</div>
|
||||
{% if error %}
|
||||
<div class="error-msg">{{ error }}</div>
|
||||
{% endif %}
|
||||
<form method="post" action="/admin/login/">
|
||||
<div class="form-group">
|
||||
<label for="username">用户名</label>
|
||||
<input type="text" id="username" name="username" class="form-control" placeholder="请输入用户名" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">密码</label>
|
||||
<input type="password" id="password" name="password" class="form-control" placeholder="请输入密码" required>
|
||||
</div>
|
||||
<button type="submit" class="btn">登 录</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="copyright">LiteAdmin v1.0 © 2026</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,65 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}运行日志 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <span>运行日志</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>运行日志</h2>
|
||||
<div>
|
||||
<form method="get" style="display:flex;gap:8px;align-items:center;">
|
||||
<select name="level" class="form-control" style="width:auto;" onchange="this.form.submit()">
|
||||
<option value="">全部级别</option>
|
||||
<option value="DEBUG" {% if level == 'DEBUG' %}selected{% endif %}>DEBUG</option>
|
||||
<option value="INFO" {% if level == 'INFO' %}selected{% endif %}>INFO</option>
|
||||
<option value="WARNING" {% if level == 'WARNING' %}selected{% endif %}>WARNING</option>
|
||||
<option value="ERROR" {% if level == 'ERROR' %}selected{% endif %}>ERROR</option>
|
||||
<option value="CRITICAL" {% if level == 'CRITICAL' %}selected{% endif %}>CRITICAL</option>
|
||||
</select>
|
||||
<input type="text" name="search" class="form-control" style="width:200px;" placeholder="搜索日志..." value="{{ search or '' }}">
|
||||
<button type="submit" class="btn btn-primary btn-sm">筛选</button>
|
||||
<a href="/admin/logs/" class="btn btn-sm">重置</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>日志列表</h3>
|
||||
<span style="font-size:13px;color:var(--text-light);">自动刷新中</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="log-viewer" id="logViewer">
|
||||
{% if logs %}
|
||||
{% for log in logs %}
|
||||
<div class="log-entry log-{{ log.level }}">[{{ log.time }}] [{{ log.level }}] [{{ log.module }}] {{ log.message }}</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="log-entry" style="color:#94a3b8;">暂无日志记录</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function refreshLogs() {
|
||||
var level = document.querySelector('select[name="level"]').value || '';
|
||||
var search = document.querySelector('input[name="search"]').value || '';
|
||||
var url = '/admin/api/logs/?level=' + encodeURIComponent(level) + '&search=' + encodeURIComponent(search);
|
||||
fetch(url)
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
var viewer = document.getElementById('logViewer');
|
||||
var html = '';
|
||||
data.logs.forEach(function(log) {
|
||||
html += '<div class="log-entry log-' + log.level + '">[' + log.time + '] [' + log.level + '] [' + log.module + '] ' + log.message + '</div>';
|
||||
});
|
||||
if (!html) {
|
||||
html = '<div class="log-entry" style="color:#94a3b8;">暂无日志记录</div>';
|
||||
}
|
||||
viewer.innerHTML = html;
|
||||
viewer.scrollTop = viewer.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(refreshLogs, 3000);
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,46 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}{{ verbose_name }}详情 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <a href="/admin/{{ model_name }}/">{{ verbose_name }}管理</a> / <span>详情 #{{ obj.id }}</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>{{ verbose_name }} #{{ obj.id }}</h2>
|
||||
<div>
|
||||
{% if can_edit %}
|
||||
<a href="/admin/{{ model_name }}/{{ obj.id }}/edit/" class="btn btn-primary">编辑</a>
|
||||
{% endif %}
|
||||
<a href="/admin/{{ model_name }}/" class="btn">返回列表</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>基本信息</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tbody>
|
||||
{% for field in detail_fields %}
|
||||
<tr>
|
||||
<td style="width:200px;font-weight:500;padding:10px 14px;border-bottom:1px solid var(--border);">{{ field.verbose_name or field.name }}</td>
|
||||
<td style="padding:10px 14px;border-bottom:1px solid var(--border);">{{ field.render(obj) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if can_delete %}
|
||||
<div class="card" style="border-color: var(--danger);">
|
||||
<div class="card-header" style="color: var(--danger);">
|
||||
<h3>危险操作</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p style="margin-bottom:12px;color:var(--text-light);">删除后将无法恢复,请谨慎操作。</p>
|
||||
<form method="post" action="/admin/{{ model_name }}/{{ obj.id }}/delete/" onsubmit="return confirm('确定要删除这个{{ verbose_name }}吗?');">
|
||||
<button type="submit" class="btn btn-danger">删除此{{ verbose_name }}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,47 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}{{ title }} - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <a href="/admin/{{ model_name }}/">{{ verbose_name }}管理</a> / <span>{{ title }}</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>{{ title }}</h2>
|
||||
<div>
|
||||
<a href="/admin/{{ model_name }}/" class="btn">返回列表</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" {% if has_file %}enctype="multipart/form-data"{% endif %}>
|
||||
{% for field in fields %}
|
||||
<div class="form-group">
|
||||
<label for="{{ field.name }}">{{ field.verbose_name or field.name }}</label>
|
||||
{% if field.type == 'textarea' %}
|
||||
<textarea id="{{ field.name }}" name="{{ field.name }}" class="form-control" {% if field.required %}required{% endif %}>{{ field.value or '' }}</textarea>
|
||||
{% elif field.type == 'select' %}
|
||||
<select id="{{ field.name }}" name="{{ field.name }}" class="form-control">
|
||||
{% for opt in field.options %}
|
||||
<option value="{{ opt.value }}" {% if field.value == opt.value %}selected{% endif %}>{{ opt.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% elif field.type == 'file' %}
|
||||
<input type="file" id="{{ field.name }}" name="{{ field.name }}" class="form-control">
|
||||
{% if field.value %}<div class="form-hint">当前文件: {{ field.value }}</div>{% endif %}
|
||||
{% elif field.type == 'boolean' %}
|
||||
<select id="{{ field.name }}" name="{{ field.name }}" class="form-control">
|
||||
<option value="1" {% if field.value %}selected{% endif %}>是</option>
|
||||
<option value="0" {% if not field.value %}selected{% endif %}>否</option>
|
||||
</select>
|
||||
{% else %}
|
||||
<input type="{{ field.input_type or 'text' }}" id="{{ field.name }}" name="{{ field.name }}" class="form-control" value="{{ field.value or '' }}" {% if field.required %}required{% endif %}>
|
||||
{% endif %}
|
||||
{% if field.hint %}<div class="form-hint">{{ field.hint }}</div>{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div style="margin-top:24px;display:flex;gap:8px;">
|
||||
<button type="submit" class="btn btn-primary">保存</button>
|
||||
<a href="/admin/{{ model_name }}/" class="btn">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,102 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}{{ verbose_name }} - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <span>{{ verbose_name }}</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>{{ verbose_name }}</h2>
|
||||
<div>
|
||||
{% if can_add %}
|
||||
<a href="/admin/{{ model_name }}/add/" class="btn btn-primary">+ 新增</a>
|
||||
{% endif %}
|
||||
{% if can_import %}
|
||||
<a href="/admin/user/import/" class="btn">📥 批量导入</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
{% if search_fields %}
|
||||
<div class="card-body" style="padding-bottom: 0;">
|
||||
<form method="get" class="search-box">
|
||||
<input type="text" name="q" class="form-control" placeholder="搜索..." value="{{ search_query or '' }}">
|
||||
<button type="submit" class="btn btn-primary">搜索</button>
|
||||
{% if search_query %}<a href="/admin/{{ model_name }}/" class="btn">清除</a>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
{% if items %}
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for field in list_fields %}
|
||||
<th>{{ field.verbose_name or field.name }}</th>
|
||||
{% endfor %}
|
||||
<th style="width:120px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in items %}
|
||||
<tr>
|
||||
{% for field in list_fields %}
|
||||
<td>
|
||||
{% if loop.first %}
|
||||
<a href="/admin/{{ model_name }}/{{ item.id }}/">{{ field.render(item) }}</a>
|
||||
{% else %}
|
||||
{{ field.render(item) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
<td>
|
||||
<a href="/admin/{{ model_name }}/{{ item.id }}/" class="btn btn-sm">查看</a>
|
||||
{% if can_edit %}
|
||||
<a href="/admin/{{ model_name }}/{{ item.id }}/edit/" class="btn btn-sm">编辑</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if pagination.total_pages > 1 %}
|
||||
<div class="pagination">
|
||||
{% if pagination.has_prev %}
|
||||
<a href="?page={{ pagination.prev_page }}{% if search_query %}&q={{ search_query }}{% endif %}">« 上一页</a>
|
||||
{% else %}
|
||||
<span class="disabled">« 上一页</span>
|
||||
{% endif %}
|
||||
|
||||
{% for p in range(1, pagination.total_pages + 1) %}
|
||||
{% if p == pagination.page %}
|
||||
<span class="active">{{ p }}</span>
|
||||
{% elif p <= 5 or p > pagination.total_pages - 2 or (p >= pagination.page - 2 and p <= pagination.page + 2) %}
|
||||
<a href="?page={{ p }}{% if search_query %}&q={{ search_query }}{% endif %}">{{ p }}</a>
|
||||
{% elif loop.index == 6 or p == pagination.total_pages - 2 %}
|
||||
<span>...</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if pagination.has_next %}
|
||||
<a href="?page={{ pagination.next_page }}{% if search_query %}&q={{ search_query }}{% endif %}">下一页 »</a>
|
||||
{% else %}
|
||||
<span class="disabled">下一页 »</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div style="text-align:center;margin-top:8px;font-size:13px;color:var(--text-light);">
|
||||
共 {{ pagination.total }} 条,第 {{ pagination.page }}/{{ pagination.total_pages }} 页
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="icon">📄</div>
|
||||
<p>暂无 {{ verbose_name }} 数据</p>
|
||||
{% if can_add %}
|
||||
<a href="/admin/{{ model_name }}/add/" class="btn btn-primary" style="margin-top:12px;">新增{{ verbose_name }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,56 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}批量导入用户 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <a href="/admin/user/">用户管理</a> / <span>批量导入</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>批量导入用户</h2>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{% if message %}
|
||||
<div class="alert alert-success">{{ message }}</div>
|
||||
{% endif %}
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label>上传 Excel 或 CSV 文件</label>
|
||||
<input type="file" name="file" accept=".xlsx,.xls,.csv" class="form-control" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">导入</button>
|
||||
<a href="/admin/user/" class="btn">返回用户列表</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">文件格式说明</div>
|
||||
<div class="card-body">
|
||||
<p>支持 <code>.xlsx</code>、<code>.xls</code> 和 <code>.csv</code> 格式。</p>
|
||||
<p>第一行必须为列标题,支持以下列:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>列名</th>
|
||||
<th>必填</th>
|
||||
<th>说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>username</td><td>是</td><td>用户名(唯一)</td></tr>
|
||||
<tr><td>password</td><td>是</td><td>登录密码</td></tr>
|
||||
<tr><td>email</td><td>否</td><td>邮箱地址</td></tr>
|
||||
<tr><td>role</td><td>否</td><td>角色:admin / editor / viewer(默认 viewer)</td></tr>
|
||||
<tr><td>level</td><td>否</td><td>等级:lv0~lv5(默认 lv1)</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="margin-top:12px;">示例 CSV:</p>
|
||||
<pre><code>username,password,email,role,level
|
||||
张三,abc123,zhangsan@test.com,viewer,lv1
|
||||
李四,def456,lisi@test.com,viewer,lv2</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user