게시물 저장 중 추가 변경 보존 및 v1.10.0 반영

This commit is contained in:
2026-07-01 15:24:55 +09:00
parent 853bec747e
commit 0eca6b288e
11 changed files with 52 additions and 13 deletions

View File

@@ -685,6 +685,9 @@ const isRouteLeaveDirty = computed(() => {
if (!hasUnsavedPostChanges.value) {
return false
}
if (props.saving) {
return true
}
if (['publishedLive', 'scheduled', 'members', 'private'].includes(persistedPublishKind.value)) {
return true
}
@@ -1482,10 +1485,11 @@ const unpublishModalKind = computed(() => (
/**
* 현재 입력값을 저장 완료 기준점으로 표시한다.
* @param {Object|null} [savedPayload] - 실제 서버에 저장된 입력값
* @returns {void}
*/
const markSaved = () => {
savedPostSnapshot.value = serializePostPayload()
const markSaved = (savedPayload = null) => {
savedPostSnapshot.value = savedPayload ? JSON.stringify(savedPayload) : serializePostPayload()
const publishedAt = resolvePayloadPublishedAt()
if (publishedAt) {
@@ -1556,6 +1560,26 @@ watch(serializedPostFingerprint, () => {
}, 1200)
})
watch(() => [props.saving, props.autoSaving], ([saving, autoSaving]) => {
if (!import.meta.client || saving || autoSaving) {
return
}
if (!shouldServerAutosaveDraft.value || !hasUnsavedPostChanges.value || !canPersistDraftPayload.value) {
return
}
window.clearTimeout(draftPersistTimer)
draftPersistTimer = window.setTimeout(() => {
if (props.saving || props.autoSaving) {
return
}
if (!shouldServerAutosaveDraft.value || !hasUnsavedPostChanges.value || !canPersistDraftPayload.value) {
return
}
emit('autosave', createPostPayload())
}, 250)
})
onMounted(() => {
if (!props.initialPost?.id && !String(form.slug || '').trim()) {
const suffix = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'