This commit is contained in:
1 parent
47e0ac34aa
commit
3f33f8fe20
9 files changed
+32
-10
No files matched your search
@@ -379,8 +379,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- hidden textarea for form submission -->
|
|
||||||
<textarea name="content" style="display:none;" {value}></textarea>
|
|
||||||
<div bind:this={editorContainer} class="editor-container"></div>
|
<div bind:this={editorContainer} class="editor-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,12 @@ export const actions: Actions = {
|
|||||||
const slug = formData.get('slug')?.toString().trim();
|
const slug = formData.get('slug')?.toString().trim();
|
||||||
const content = formData.get('content')?.toString() || '';
|
const content = formData.get('content')?.toString() || '';
|
||||||
|
|
||||||
if (!title || !slug || !content) {
|
const missing: string[] = [];
|
||||||
return fail(400, { error: '标题、URL 别名和正文为必填项' });
|
if (!title) missing.push('标题');
|
||||||
|
if (!slug) missing.push('URL 别名');
|
||||||
|
if (!content) missing.push('正文');
|
||||||
|
if (missing.length > 0) {
|
||||||
|
return fail(400, { error: `${missing.join('、')}为必填项` });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form action="?/update" method="POST" id="page-form" class="post-form">
|
<form action="?/update" method="POST" id="page-form" class="post-form">
|
||||||
|
<!-- 正文由页面统一持有并始终提交,避免切到「预览」时编辑器卸载导致正文丢失 -->
|
||||||
|
<input type="hidden" name="content" value={content} />
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
<div class="form-main">
|
<div class="form-main">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ export const actions: Actions = {
|
|||||||
const slug = formData.get('slug')?.toString().trim();
|
const slug = formData.get('slug')?.toString().trim();
|
||||||
const content = formData.get('content')?.toString() || '';
|
const content = formData.get('content')?.toString() || '';
|
||||||
|
|
||||||
if (!title || !slug || !content) {
|
const missing: string[] = [];
|
||||||
return fail(400, { error: '标题、URL 别名和正文为必填项' });
|
if (!title) missing.push('标题');
|
||||||
|
if (!slug) missing.push('URL 别名');
|
||||||
|
if (!content) missing.push('正文');
|
||||||
|
if (missing.length > 0) {
|
||||||
|
return fail(400, { error: `${missing.join('、')}为必填项` });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -54,6 +54,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form method="POST" id="page-form" class="post-form">
|
<form method="POST" id="page-form" class="post-form">
|
||||||
|
<!-- 正文由页面统一持有并始终提交,避免切到「预览」时编辑器卸载导致正文丢失 -->
|
||||||
|
<input type="hidden" name="content" value={content} />
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
<div class="form-main">
|
<div class="form-main">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -87,8 +87,12 @@ export const actions: Actions = {
|
|||||||
const publishedAt = formData.get('published_at')?.toString().trim();
|
const publishedAt = formData.get('published_at')?.toString().trim();
|
||||||
const updatedAt = formData.get('updated_at')?.toString().trim() || new Date().toISOString();
|
const updatedAt = formData.get('updated_at')?.toString().trim() || new Date().toISOString();
|
||||||
|
|
||||||
if (!title || !slug || !content) {
|
const missing: string[] = [];
|
||||||
return fail(400, { error: '标题、URL 别名和文章正文为必填项' });
|
if (!title) missing.push('标题');
|
||||||
|
if (!slug) missing.push('URL 别名');
|
||||||
|
if (!content) missing.push('文章正文');
|
||||||
|
if (missing.length > 0) {
|
||||||
|
return fail(400, { error: `${missing.join('、')}为必填项` });
|
||||||
}
|
}
|
||||||
|
|
||||||
let seriesId: number | null;
|
let seriesId: number | null;
|
||||||
|
|||||||
@@ -122,6 +122,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form method="POST" action="?/update" id="post-form" class="post-form">
|
<form method="POST" action="?/update" id="post-form" class="post-form">
|
||||||
|
<!-- 正文由页面统一持有并始终提交,避免切到「预览」时编辑器卸载导致正文丢失 -->
|
||||||
|
<input type="hidden" name="content" value={content} />
|
||||||
<input type="hidden" name="published_at" value={publishedAt} />
|
<input type="hidden" name="published_at" value={publishedAt} />
|
||||||
<input type="hidden" name="updated_at" value={updatedAt} />
|
<input type="hidden" name="updated_at" value={updatedAt} />
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
|
|||||||
@@ -52,8 +52,12 @@ export const actions: Actions = {
|
|||||||
const publishedAt = formData.get('published_at')?.toString().trim() || new Date().toISOString();
|
const publishedAt = formData.get('published_at')?.toString().trim() || new Date().toISOString();
|
||||||
const updatedAt = formData.get('updated_at')?.toString().trim() || publishedAt;
|
const updatedAt = formData.get('updated_at')?.toString().trim() || publishedAt;
|
||||||
|
|
||||||
if (!title || !slug || !content) {
|
const missing: string[] = [];
|
||||||
return fail(400, { error: '标题、URL 别名和文章正文为必填项' });
|
if (!title) missing.push('标题');
|
||||||
|
if (!slug) missing.push('URL 别名');
|
||||||
|
if (!content) missing.push('文章正文');
|
||||||
|
if (missing.length > 0) {
|
||||||
|
return fail(400, { error: `${missing.join('、')}为必填项` });
|
||||||
}
|
}
|
||||||
|
|
||||||
let seriesId: number | null;
|
let seriesId: number | null;
|
||||||
|
|||||||
@@ -142,6 +142,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form method="POST" id="post-form" class="post-form">
|
<form method="POST" id="post-form" class="post-form">
|
||||||
|
<!-- 正文由页面统一持有并始终提交,避免切到「预览」时编辑器卸载导致正文丢失 -->
|
||||||
|
<input type="hidden" name="content" value={content} />
|
||||||
<input type="hidden" name="published_at" value={publishedAt} />
|
<input type="hidden" name="published_at" value={publishedAt} />
|
||||||
<input type="hidden" name="updated_at" value={updatedAt} />
|
<input type="hidden" name="updated_at" value={updatedAt} />
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
|
|||||||
Reference in new issue
Block a user