mirror of https://github.com/halo-dev/halo-admin
Fixed #6
parent
2085b1d6fb
commit
93919c4e9e
|
@ -29,19 +29,25 @@ postApi.get = postId => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
postApi.create = postToCreate => {
|
postApi.create = (postToCreate, autoSave) => {
|
||||||
return service({
|
return service({
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: postToCreate
|
data: postToCreate,
|
||||||
|
params: {
|
||||||
|
autoSave: autoSave
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
postApi.update = (postId, postToUpdate) => {
|
postApi.update = (postId, postToUpdate, autoSave) => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/${postId}`,
|
url: `${baseUrl}/${postId}`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: postToUpdate
|
data: postToUpdate,
|
||||||
|
params: {
|
||||||
|
autoSave: autoSave
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ export default {
|
||||||
this.options = response.data.data
|
this.options = response.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
createOrUpdatePost(createSuccess, updateSuccess) {
|
createOrUpdatePost(createSuccess, updateSuccess, autoSave) {
|
||||||
// Set category ids
|
// Set category ids
|
||||||
this.postToStage.categoryIds = this.selectedCategoryIds
|
this.postToStage.categoryIds = this.selectedCategoryIds
|
||||||
// Set tag ids
|
// Set tag ids
|
||||||
|
@ -296,7 +296,7 @@ export default {
|
||||||
|
|
||||||
if (this.postToStage.id) {
|
if (this.postToStage.id) {
|
||||||
// Update the post
|
// 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)
|
this.$log.debug('Updated post', response.data.data)
|
||||||
if (updateSuccess) {
|
if (updateSuccess) {
|
||||||
updateSuccess()
|
updateSuccess()
|
||||||
|
@ -304,7 +304,7 @@ export default {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Create the post
|
// Create the post
|
||||||
postApi.create(this.postToStage).then(response => {
|
postApi.create(this.postToStage, autoSave).then(response => {
|
||||||
this.$log.debug('Created post', response.data.data)
|
this.$log.debug('Created post', response.data.data)
|
||||||
if (createSuccess) {
|
if (createSuccess) {
|
||||||
createSuccess()
|
createSuccess()
|
||||||
|
@ -314,11 +314,15 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
savePost() {
|
savePost() {
|
||||||
this.createOrUpdatePost(() => this.$message.success('文章创建成功'), () => this.$message.success('文章更新成功'))
|
this.createOrUpdatePost(
|
||||||
|
() => this.$message.success('文章创建成功'),
|
||||||
|
() => this.$message.success('文章更新成功'),
|
||||||
|
false
|
||||||
|
)
|
||||||
},
|
},
|
||||||
autoSavePost() {
|
autoSavePost() {
|
||||||
if (this.postToStage.title != null && this.postToStage.originalContent != null) {
|
if (this.postToStage.title != null && this.postToStage.originalContent != null) {
|
||||||
this.createOrUpdatePost()
|
this.createOrUpdatePost(null, null, true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleCategoryForm() {
|
toggleCategoryForm() {
|
||||||
|
|
Loading…
Reference in New Issue