From b658eeb8e9aced0e60f0d715086c39af37ee3dfa Mon Sep 17 00:00:00 2001 From: Victor_Jay Date: Sun, 31 May 2026 20:06:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=96=E8=BE=91=E5=99=A8=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E6=96=87=E7=AB=A0=E6=8F=90=E7=A4=BA=20-=20=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E7=BC=96=E8=BE=91=EF=BC=8C=E6=98=BE=E7=A4=BA=E6=98=8E?= =?UTF-8?q?=E7=A1=AE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /studio/write?id=X 路由:文章被锁定时,页面显示紫色锁定横幅,标题/编辑器只读,提交按钮替换为锁定提示 - studio-editor.js:锁定态下 Vditor 设为 readonly 模式,隐藏工具栏,禁用 Ctrl+S 快捷键 - 新增 .studio-locked-banner / .locked-submit-hint 样式 --- internal/controller/studio_controller.go | 1 + templates/MetaLab-2026/html/studio/write.html | 18 ++++++++- templates/MetaLab-2026/static/css/studio.css | 38 +++++++++++++++++++ .../MetaLab-2026/static/js/studio-editor.js | 20 ++++++---- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/internal/controller/studio_controller.go b/internal/controller/studio_controller.go index 4ffe6da..1bb98ec 100644 --- a/internal/controller/studio_controller.go +++ b/internal/controller/studio_controller.go @@ -154,6 +154,7 @@ func (ctrl *StudioController) WritePage(c *gin.Context) { "Post": post, "ActiveTab": "write", "ExtraCSS": "/static/css/studio.css", + "StatusNames": common.PostStatusDisplayNames, })) return } diff --git a/templates/MetaLab-2026/html/studio/write.html b/templates/MetaLab-2026/html/studio/write.html index da4ec38..5bc44e7 100644 --- a/templates/MetaLab-2026/html/studio/write.html +++ b/templates/MetaLab-2026/html/studio/write.html @@ -8,9 +8,20 @@
+ {{if and .Post .Post.IsLocked}} +
+
🔒
+
+ 这篇文章已被锁定,无法编辑。 +

如需解锁请联系管理员。当前状态:{{if $.StatusNames}}{{index $.StatusNames .Post.Status}}、已锁定{{end}}

+
+
+ {{end}} +
{{if .Post}} + {{end}} @@ -18,7 +29,8 @@ + maxlength="200" required autofocus + {{if and .Post .Post.IsLocked}}disabled{{end}}>
@@ -55,7 +67,11 @@ 0 字 + {{if and .Post .Post.IsLocked}} + 🔒 此文已锁定,无法修改 + {{else}} + {{end}}
diff --git a/templates/MetaLab-2026/static/css/studio.css b/templates/MetaLab-2026/static/css/studio.css index 57f8d3a..ae15f19 100644 --- a/templates/MetaLab-2026/static/css/studio.css +++ b/templates/MetaLab-2026/static/css/studio.css @@ -460,6 +460,44 @@ color: #fff; } +/* ---------- 锁定提示 ---------- */ +.studio-locked-banner { + display: flex; + gap: 14px; + align-items: center; + padding: 16px 20px; + margin-bottom: 20px; + background: #f3e5f5; + border: 1px solid #ce93d8; + border-radius: var(--radius); + color: #6a1b9a; + font-size: 14px; +} + +.studio-locked-banner p { + margin: 4px 0 0; + font-size: 13px; + color: #8e24aa; +} + +.studio-locked-banner strong { + font-size: 15px; +} + +.locked-banner-icon { + font-size: 28px; + flex-shrink: 0; +} + +.locked-submit-hint { + font-size: 14px; + color: #6a1b9a; + font-weight: 600; + padding: 8px 16px; + background: #f3e5f5; + border-radius: 8px; +} + /* ---------- 占位提示 ---------- */ .studio-placeholder { text-align: center; diff --git a/templates/MetaLab-2026/static/js/studio-editor.js b/templates/MetaLab-2026/static/js/studio-editor.js index 666cf26..86c061b 100644 --- a/templates/MetaLab-2026/static/js/studio-editor.js +++ b/templates/MetaLab-2026/static/js/studio-editor.js @@ -18,6 +18,7 @@ document.addEventListener('DOMContentLoaded', () => { const postId = document.getElementById('postId')?.value const isEdit = !!postId + const isLocked = document.getElementById('isLocked')?.value === '1' let initialMD = '' const editBodyEl = document.getElementById('editBody') @@ -30,9 +31,10 @@ document.addEventListener('DOMContentLoaded', () => { cdn: '/static/vditor', height: '100%', lang: 'zh_CN', - placeholder: '在此输入正文...', + placeholder: isLocked ? '此文已锁定,不可编辑' : '在此输入正文...', + readonly: isLocked, - toolbar: [ + toolbar: isLocked ? [] : [ 'headings', 'bold', 'italic', 'strike', '|', 'line', 'code', 'inline-code', 'link', 'quote', '|', 'list', 'ordered-list', 'check', 'outdent', 'indent', '|', @@ -100,12 +102,14 @@ document.addEventListener('DOMContentLoaded', () => { document.getElementById('postForm')?.addEventListener('submit', handleSubmit) - document.addEventListener('keydown', (e) => { - if ((e.ctrlKey || e.metaKey) && e.key === 's') { - e.preventDefault() - document.getElementById('postForm')?.dispatchEvent(new Event('submit')) - } - }) + if (!isLocked) { + document.addEventListener('keydown', (e) => { + if ((e.ctrlKey || e.metaKey) && e.key === 's') { + e.preventDefault() + document.getElementById('postForm')?.dispatchEvent(new Event('submit')) + } + }) + } }) function updateWordCount() {