diff --git a/src/api/post.js b/src/api/post.js index 0f2cd7d1..9fee5b9a 100644 --- a/src/api/post.js +++ b/src/api/post.js @@ -29,19 +29,25 @@ postApi.get = postId => { }) } -postApi.create = postToCreate => { +postApi.create = (postToCreate, autoSave) => { return service({ url: baseUrl, method: 'post', - data: postToCreate + data: postToCreate, + params: { + autoSave: autoSave + } }) } -postApi.update = (postId, postToUpdate) => { +postApi.update = (postId, postToUpdate, autoSave) => { return service({ url: `${baseUrl}/${postId}`, method: 'put', - data: postToUpdate + data: postToUpdate, + params: { + autoSave: autoSave + } }) } @@ -76,4 +82,4 @@ postApi.postStatus = { text: '回收站' } } -export default postApi +export default postApi \ No newline at end of file diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index 8aab3a21..3eeb5559 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -288,7 +288,7 @@ export default { this.options = response.data.data }) }, - createOrUpdatePost(createSuccess, updateSuccess) { + createOrUpdatePost(createSuccess, updateSuccess, autoSave) { // Set category ids this.postToStage.categoryIds = this.selectedCategoryIds // Set tag ids @@ -296,7 +296,7 @@ export default { if (this.postToStage.id) { // Update the post - postApi.update(this.postToStage.id, this.postToStage).then(response => { + postApi.update(this.postToStage.id, this.postToStage, autoSave).then(response => { this.$log.debug('Updated post', response.data.data) if (updateSuccess) { updateSuccess() @@ -304,7 +304,7 @@ export default { }) } else { // Create the post - postApi.create(this.postToStage).then(response => { + postApi.create(this.postToStage, autoSave).then(response => { this.$log.debug('Created post', response.data.data) if (createSuccess) { createSuccess() @@ -314,11 +314,15 @@ export default { } }, savePost() { - this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功')) + this.createOrUpdatePost( + () => this.$message.success('文章创建成功'), + () => this.$message.success('文章更新成功'), + false + ) }, autoSavePost() { if (this.postToStage.title != null && this.postToStage.originalContent != null) { - this.createOrUpdatePost() + this.createOrUpdatePost(null, null, true) } }, toggleCategoryForm() {