feat: 编辑器锁定文章提示 - 禁用编辑,显示明确提示

- /studio/write?id=X 路由:文章被锁定时,页面显示紫色锁定横幅,标题/编辑器只读,提交按钮替换为锁定提示
- studio-editor.js:锁定态下 Vditor 设为 readonly 模式,隐藏工具栏,禁用 Ctrl+S 快捷键
- 新增 .studio-locked-banner / .locked-submit-hint 样式
This commit is contained in:
2026-05-31 20:06:32 +08:00
parent 99d0891413
commit b658eeb8e9
4 changed files with 68 additions and 9 deletions

View File

@ -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() {