From 51b7e714cc3771b884bd5e4985a1f1ba6119eb0d Mon Sep 17 00:00:00 2001 From: johnniang Date: Sat, 4 Jan 2020 21:11:16 +0800 Subject: [PATCH] Enable draft only saving --- src/api/post.js | 10 ++++++++++ src/views/post/PostEdit.vue | 24 ++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/api/post.js b/src/api/post.js index 37a3979a1..9653e35d7 100644 --- a/src/api/post.js +++ b/src/api/post.js @@ -51,6 +51,16 @@ postApi.update = (postId, postToUpdate, autoSave) => { }) } +postApi.updateDraft = (postId, content) => { + return service({ + url: `${baseUrl}/${postId}/status/draft/content`, + method: 'put', + data: { + content: content + } + }) +} + postApi.updateStatus = (postId, status) => { return service({ url: `${baseUrl}/${postId}/status/${status}`, diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index 20457c413..3a3e11787 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -19,7 +19,7 @@ :ishljs="true" :autofocus="false" @imgAdd="handleAttachmentUpload" - @save="handleSaveDraft" + @save="handleSaveDraft(true)" /> @@ -44,7 +44,7 @@ 保存草稿 { - this.$log.debug('Updated post', response.data.data) - this.$message.success('保存草稿成功!') - this.saving = false - }) + if (draftOnly) { + postApi.updateDraft(this.postToStage.id, this.postToStage.originalContent).then(response => { + this.$message.success('保存草稿成功!') + this.saving = false + }) + } else { + postApi.update(this.postToStage.id, this.postToStage, false).then(response => { + this.$log.debug('Updated post', response.data.data) + this.$message.success('保存草稿成功!') + this.saving = false + }) + } } else { // Create the post postApi.create(this.postToStage, false).then(response => {