관리자 글쓰기·목록 UX 개선 및 POST 설정 추가(v1.1.14~v1.1.18)

Ghost형 툴바·초안 자동 저장·발행 모달, private 제거, 미디어 모달 통합,
발행일·수정일 표시 설정과 DB 마이그레이션 025·026을 반영한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-15 16:26:48 +09:00
parent ca1e17890b
commit 2074b0b93a
26 changed files with 1184 additions and 393 deletions

View File

@@ -6,6 +6,7 @@ definePageMeta({
const route = useRoute()
const id = computed(() => String(route.params.id || ''))
const saving = ref(false)
const autoSaving = ref(false)
const deleting = ref(false)
const errorMessage = ref('')
const postForm = ref(null)
@@ -106,6 +107,43 @@ const savePost = async (payload) => {
}
}
/**
* 초안 자동 저장(디바운스 PUT) — 발행·예약 글에는 사용하지 않는다.
* @param {Object} payload - `createPostPayload`와 동일 구조
* @returns {Promise<void>}
*/
const autosaveDraftPost = async (payload) => {
if (!id.value || autoSaving.value) {
return
}
autoSaving.value = true
try {
const updatedPost = await $fetch(`/admin/api/posts/${id.value}`, {
method: 'PUT',
body: payload
})
post.value = updatedPost
postForm.value?.markSaved()
} catch (error) {
const msg = error?.data?.message || error?.message || '자동 저장에 실패했습니다.'
showToast('error', msg)
} finally {
autoSaving.value = false
}
}
onBeforeRouteLeave(async () => {
await nextTick()
const payload = postForm.value?.takePendingAutosavePayload?.()
if (!payload) {
return true
}
await autosaveDraftPost(payload)
return true
})
/**
* 게시물 삭제
* @returns {Promise<void>} 삭제 처리 결과
@@ -148,13 +186,14 @@ onBeforeUnmount(() => {
<AdminPostForm
ref="postForm"
:initial-post="post"
submit-label="변경 저장"
:saving="saving"
:auto-saving="autoSaving"
:can-view-post="isPublicPost(post)"
:public-url="publicPostUrl"
:deleting="deleting"
show-delete
@submit="savePost"
@autosave="autosaveDraftPost"
@preview="previewPost"
@delete="deletePost"
/>