完善: CSRF安全修复 + 后台任务管理 + 压测全模块覆盖 + 文档

This commit is contained in:
张志挺
2026-08-26 15:21:48 +08:00
parent f39008193f
commit 36ac5f737b
61 changed files with 7281 additions and 867 deletions
+52
View File
@@ -0,0 +1,52 @@
{% extends "base.html" %}
{% block title %}记事本详情{% endblock %}
{% block content %}
<div class="page-title" id="note-header">
<h1 id="note-title"></h1>
<p id="note-meta"></p>
</div>
<div class="card">
<div class="card-body">
<div class="prose" id="note-content"></div>
</div>
</div>
<div style="display:flex;gap:8px;margin-top:16px;">
<a href="/notes/" class="btn">&larr; 返回列表</a>
<a href="javascript:void(0)" id="edit-btn" class="btn btn-primary">编辑</a>
<a href="javascript:void(0)" id="pin-btn" class="btn">置顶切换</a>
<a href="javascript:void(0)" id="delete-btn" class="btn btn-danger">删除</a>
</div>
<script>
(async function() {
var id = window.location.pathname.match(/\/notes\/(\d+)\//)[1];
var res = await fetch('/api/notes/' + id + '/');
var data = await res.json();
if (!data.success) { window.location.href = '/notes/'; return; }
var n = data.note;
document.getElementById('note-title').textContent = n.title;
document.getElementById('note-meta').innerHTML = '创建于 ' + n.created_at + ' &middot; 更新于 ' + n.updated_at + (n.is_pinned ? ' &middot; 📌 已置顶' : '');
document.getElementById('note-content').innerHTML = n.content.replace(/\n/g, '<br>');
document.getElementById('edit-btn').href = '/notes/' + id + '/edit/';
document.getElementById('pin-btn').onclick = async function() {
var fd = new FormData();
fd.append('csrf_token', CSRF_TOKEN);
var r = await fetch('/api/notes/' + id + '/pin/', { method: 'POST', body: fd });
var j = await r.json();
if (j.success) window.location.reload();
};
document.getElementById('delete-btn').onclick = async function() {
if (!confirm('确定删除这条记事吗?')) return;
var fd = new FormData();
fd.append('csrf_token', CSRF_TOKEN);
var r = await fetch('/api/notes/' + id + '/delete/', { method: 'POST', body: fd });
var j = await r.json();
if (j.success) window.location.href = '/notes/';
};
})();
</script>
{% endblock %}