feat: 锁定文章需填写锁定理由,编辑器显示锁定理由

- Post 模型新增 LockReason 字段,锁定必填理由,解锁清空
- PostLockRequest DTO:reason 必填,1-500字
- Admin JS:锁定操作弹出 prompt 要求填写理由
- 编辑器锁定横幅显示"锁定理由:XXX",理由为空时不显示该行
This commit is contained in:
2026-05-31 20:10:55 +08:00
parent b658eeb8e9
commit 968e8af8a3
8 changed files with 23 additions and 6 deletions

View File

@ -13,7 +13,9 @@
<div class="locked-banner-icon">🔒</div>
<div>
<strong>这篇文章已被锁定,无法编辑。</strong>
<p>如需解锁请联系管理员。当前状态:{{if $.StatusNames}}{{index $.StatusNames .Post.Status}}、已锁定{{end}}</p>
{{if .Post.LockReason}}
<p>锁定理由:{{.Post.LockReason}}</p>
{{end}}
</div>
</div>
{{end}}

View File

@ -47,7 +47,9 @@
// 锁定
handleClick('.post-lock', function(id) {
api('/api/admin/posts/' + id + '/lock', 'POST')
var reason = prompt('请输入锁定理由(必填):');
if (!reason || !reason.trim()) return;
api('/api/admin/posts/' + id + '/lock', 'POST', { reason: reason.trim() })
.then(function(d) { if (d.success) refreshPage(); else alert(d.message); })
.catch(function() { alert('操作失败'); });
});