完善: CSRF安全修复 + 后台任务管理 + 压测全模块覆盖 + 文档
This commit is contained in:
+116
-11
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}社区平台{% endblock %}</title>
|
||||
<title>{% block title %}{{ site_name }}{% endblock %}</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary: #2563eb;
|
||||
@@ -95,6 +95,73 @@ a:hover { color: var(--primary-dark); text-decoration: underline; }
|
||||
.header .user-area a:hover { color: #fff; }
|
||||
.header .user-area .username { color: #e2e8f0; font-size: 13px; }
|
||||
|
||||
/* 用户下拉菜单 */
|
||||
.user-dropdown {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
.user-dropdown .username {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.user-dropdown .username:hover {
|
||||
background: rgba(255,255,255,0.08);
|
||||
}
|
||||
.user-dropdown .username .arrow {
|
||||
font-size: 10px;
|
||||
color: #64748b;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.user-dropdown:hover .username .arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.user-dropdown .dropdown-menu {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
min-width: 140px;
|
||||
background: #1e293b;
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
border-radius: 8px;
|
||||
padding: 6px 0;
|
||||
box-shadow: 0 8px 24px rgba(0,0,0,0.3);
|
||||
z-index: 200;
|
||||
}
|
||||
.user-dropdown:hover .dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
.user-dropdown .dropdown-menu a,
|
||||
.user-dropdown .dropdown-menu .menu-label {
|
||||
display: block;
|
||||
padding: 8px 16px;
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
}
|
||||
.user-dropdown .dropdown-menu a:hover {
|
||||
background: rgba(255,255,255,0.08);
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.user-dropdown .dropdown-menu .menu-label {
|
||||
color: #64748b;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.user-dropdown .dropdown-menu .divider {
|
||||
height: 1px;
|
||||
background: rgba(255,255,255,0.08);
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
/* 主内容 */
|
||||
.main { flex: 1; }
|
||||
.page-content { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
|
||||
@@ -281,12 +348,14 @@ select.form-control { cursor: pointer; }
|
||||
<body>
|
||||
<div class="header">
|
||||
<div class="header-inner">
|
||||
<a href="/" class="logo">社区平台</a>
|
||||
<a href="/" class="logo">{{ site_name }}</a>
|
||||
<nav>
|
||||
<a href="/" class="{% if request.path == '/' %}active{% endif %}">首页</a>
|
||||
<a href="/announcements/" class="{% if request.path.startswith('/announcements') %}active{% endif %}">公告</a>
|
||||
<a href="/forum/" class="{% if request.path.startswith('/forum') %}active{% endif %}">论坛</a>
|
||||
<a href="/knowledge/" class="{% if request.path.startswith('/knowledge') %}active{% endif %}">知识库</a>
|
||||
<a href="/announcements/" class="{% if '/announcements' in request.path %}active{% endif %}">公告</a>
|
||||
<a href="/forum/" class="{% if '/forum' in request.path %}active{% endif %}">论坛</a>
|
||||
<a href="/knowledge/" class="{% if '/knowledge' in request.path %}active{% endif %}">知识库</a>
|
||||
<a href="/markdown-help/" class="{% if '/markdown-help' in request.path %}active{% endif %}">📝 Markdown 教程</a>
|
||||
<a href="/tasks/" class="{% if '/tasks' in request.path %}active{% endif %}">信息收集</a>
|
||||
</nav>
|
||||
<div class="search-box">
|
||||
<span class="search-icon">🔍</span>
|
||||
@@ -296,10 +365,27 @@ select.form-control { cursor: pointer; }
|
||||
</div>
|
||||
<div class="user-area">
|
||||
{% if current_user %}
|
||||
<span class="username">{{ current_user.username }}</span>
|
||||
<span class="badge badge-primary">{{ current_user.get_level_name() }}</span>
|
||||
<a href="/admin/">管理</a>
|
||||
<a href="/admin/logout/">退出</a>
|
||||
<div class="user-dropdown">
|
||||
<div class="username">
|
||||
{{ current_user.username }}
|
||||
<span class="arrow">▼</span>
|
||||
</div>
|
||||
<div class="dropdown-menu">
|
||||
<div class="menu-label">{{ current_user.level }}</div>
|
||||
<div class="divider"></div>
|
||||
<a href="/my/topics/">我的帖子</a>
|
||||
<a href="/my/replies/">我的回复</a>
|
||||
<a href="/notes/">📒 我的记事本</a>
|
||||
<a href="/favorites/">⭐ 我的收藏</a>
|
||||
{% if is_admin %}
|
||||
<div class="divider"></div>
|
||||
<a href="/admin/">管理后台</a>
|
||||
{% endif %}
|
||||
<div class="divider"></div>
|
||||
<a href="/password/">修改密码</a>
|
||||
<a href="/logout/">退出登录</a>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<a href="/login/">登录</a>
|
||||
{% endif %}
|
||||
@@ -314,10 +400,11 @@ select.form-control { cursor: pointer; }
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>社区平台 © 2026 Powered by LiteAdmin</p>
|
||||
<p>{{ site_footer|safe }}</p>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>
|
||||
var CSRF_TOKEN = '{{ csrf_token }}';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.prose table').forEach(function(t) {
|
||||
if (!t.parentElement.classList.contains('table-wrap')) {
|
||||
@@ -330,5 +417,23 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function parseUploadedFile(file, callback) {
|
||||
var name = file.name.toLowerCase();
|
||||
if (name.endsWith('.docx') || name.endsWith('.xlsx')) {
|
||||
var fd = new FormData();
|
||||
fd.append('file', file);
|
||||
fetch('/api/upload/docx/', { method: 'POST', credentials: 'same-origin', body: fd })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success && data.markdown) {
|
||||
callback(data.markdown);
|
||||
} else {
|
||||
callback('');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user