mirror of https://github.com/halo-dev/halo-admin
fix: If the post fails to save, the button will not be restored to clickable. (#68)
parent
86adfb42a1
commit
65f078efa3
|
@ -185,25 +185,37 @@ export default {
|
||||||
if (this.postToStage.id) {
|
if (this.postToStage.id) {
|
||||||
// Update the post
|
// Update the post
|
||||||
if (draftOnly) {
|
if (draftOnly) {
|
||||||
postApi.updateDraft(this.postToStage.id, this.postToStage.originalContent).then(response => {
|
postApi
|
||||||
this.$message.success('保存草稿成功!')
|
.updateDraft(this.postToStage.id, this.postToStage.originalContent)
|
||||||
this.saving = false
|
.then(response => {
|
||||||
})
|
this.$message.success('保存草稿成功!')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
postApi
|
||||||
this.$log.debug('Updated post', response.data.data)
|
.update(this.postToStage.id, this.postToStage, false)
|
||||||
this.$message.success('保存草稿成功!')
|
.then(response => {
|
||||||
this.saving = false
|
this.$log.debug('Updated post', response.data.data)
|
||||||
})
|
this.$message.success('保存草稿成功!')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create the post
|
// Create the post
|
||||||
postApi.create(this.postToStage, false).then(response => {
|
postApi
|
||||||
this.$log.debug('Created post', response.data.data)
|
.create(this.postToStage, false)
|
||||||
this.$message.success('保存草稿成功!')
|
.then(response => {
|
||||||
this.postToStage = response.data.data
|
this.$log.debug('Created post', response.data.data)
|
||||||
this.saving = false
|
this.$message.success('保存草稿成功!')
|
||||||
})
|
this.postToStage = response.data.data
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleAttachmentUpload(pos, $file) {
|
handleAttachmentUpload(pos, $file) {
|
||||||
|
@ -234,20 +246,28 @@ export default {
|
||||||
// Update the post
|
// Update the post
|
||||||
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
||||||
this.$log.debug('Updated post', response.data.data)
|
this.$log.debug('Updated post', response.data.data)
|
||||||
postApi.preview(this.postToStage.id).then(response => {
|
postApi
|
||||||
window.open(response.data, '_blank')
|
.preview(this.postToStage.id)
|
||||||
this.saving = false
|
.then(response => {
|
||||||
})
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Create the post
|
// Create the post
|
||||||
postApi.create(this.postToStage, false).then(response => {
|
postApi.create(this.postToStage, false).then(response => {
|
||||||
this.$log.debug('Created post', response.data.data)
|
this.$log.debug('Created post', response.data.data)
|
||||||
this.postToStage = response.data.data
|
this.postToStage = response.data.data
|
||||||
postApi.preview(this.postToStage.id).then(response => {
|
postApi
|
||||||
window.open(response.data, '_blank')
|
.preview(this.postToStage.id)
|
||||||
this.saving = false
|
.then(response => {
|
||||||
})
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -469,27 +469,35 @@ export default {
|
||||||
this.saving = true
|
this.saving = true
|
||||||
if (this.selectedPost.id) {
|
if (this.selectedPost.id) {
|
||||||
// Update the post
|
// Update the post
|
||||||
postApi.update(this.selectedPost.id, this.selectedPost, autoSave).then(response => {
|
postApi
|
||||||
this.$log.debug('Updated post', response.data.data)
|
.update(this.selectedPost.id, this.selectedPost, autoSave)
|
||||||
if (updateSuccess) {
|
.then(response => {
|
||||||
updateSuccess()
|
this.$log.debug('Updated post', response.data.data)
|
||||||
|
if (updateSuccess) {
|
||||||
|
updateSuccess()
|
||||||
|
this.$emit('onSaved', true)
|
||||||
|
this.$router.push({ name: 'PostList' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.saving = false
|
this.saving = false
|
||||||
this.$emit('onSaved', true)
|
})
|
||||||
this.$router.push({ name: 'PostList' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
// Create the post
|
// Create the post
|
||||||
postApi.create(this.selectedPost, autoSave).then(response => {
|
postApi
|
||||||
this.$log.debug('Created post', response.data.data)
|
.create(this.selectedPost, autoSave)
|
||||||
if (createSuccess) {
|
.then(response => {
|
||||||
createSuccess()
|
this.$log.debug('Created post', response.data.data)
|
||||||
|
if (createSuccess) {
|
||||||
|
createSuccess()
|
||||||
|
this.$emit('onSaved', true)
|
||||||
|
this.$router.push({ name: 'PostList' })
|
||||||
|
}
|
||||||
|
this.selectedPost = response.data.data
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.saving = false
|
this.saving = false
|
||||||
this.$emit('onSaved', true)
|
})
|
||||||
this.$router.push({ name: 'PostList' })
|
|
||||||
}
|
|
||||||
this.selectedPost = response.data.data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|
|
@ -171,18 +171,26 @@ export default {
|
||||||
this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
|
||||||
}
|
}
|
||||||
if (this.sheetToStage.id) {
|
if (this.sheetToStage.id) {
|
||||||
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
sheetApi
|
||||||
this.$log.debug('Updated sheet', response.data.data)
|
.update(this.sheetToStage.id, this.sheetToStage, false)
|
||||||
this.$message.success('保存草稿成功!')
|
.then(response => {
|
||||||
this.saving = false
|
this.$log.debug('Updated sheet', response.data.data)
|
||||||
})
|
this.$message.success('保存草稿成功!')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
sheetApi.create(this.sheetToStage, false).then(response => {
|
sheetApi
|
||||||
this.$log.debug('Created sheet', response.data.data)
|
.create(this.sheetToStage, false)
|
||||||
this.$message.success('保存草稿成功!')
|
.then(response => {
|
||||||
this.sheetToStage = response.data.data
|
this.$log.debug('Created sheet', response.data.data)
|
||||||
this.saving = false
|
this.$message.success('保存草稿成功!')
|
||||||
})
|
this.sheetToStage = response.data.data
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleAttachmentUpload(pos, $file) {
|
handleAttachmentUpload(pos, $file) {
|
||||||
|
@ -212,19 +220,27 @@ export default {
|
||||||
if (this.sheetToStage.id) {
|
if (this.sheetToStage.id) {
|
||||||
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
||||||
this.$log.debug('Updated sheet', response.data.data)
|
this.$log.debug('Updated sheet', response.data.data)
|
||||||
sheetApi.preview(this.sheetToStage.id).then(response => {
|
sheetApi
|
||||||
window.open(response.data, '_blank')
|
.preview(this.sheetToStage.id)
|
||||||
this.saving = false
|
.then(response => {
|
||||||
})
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sheetApi.create(this.sheetToStage, false).then(response => {
|
sheetApi.create(this.sheetToStage, false).then(response => {
|
||||||
this.$log.debug('Created sheet', response.data.data)
|
this.$log.debug('Created sheet', response.data.data)
|
||||||
this.sheetToStage = response.data.data
|
this.sheetToStage = response.data.data
|
||||||
sheetApi.preview(this.sheetToStage.id).then(response => {
|
sheetApi
|
||||||
window.open(response.data, '_blank')
|
.preview(this.sheetToStage.id)
|
||||||
this.saving = false
|
.then(response => {
|
||||||
})
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.saving = false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -304,26 +304,34 @@ export default {
|
||||||
this.selectedSheet.sheetMetas = this.selectedSheetMetas
|
this.selectedSheet.sheetMetas = this.selectedSheetMetas
|
||||||
this.saving = true
|
this.saving = true
|
||||||
if (this.selectedSheet.id) {
|
if (this.selectedSheet.id) {
|
||||||
sheetApi.update(this.selectedSheet.id, this.selectedSheet, autoSave).then(response => {
|
sheetApi
|
||||||
this.$log.debug('Updated sheet', response.data.data)
|
.update(this.selectedSheet.id, this.selectedSheet, autoSave)
|
||||||
if (updateSuccess) {
|
.then(response => {
|
||||||
updateSuccess()
|
this.$log.debug('Updated sheet', response.data.data)
|
||||||
|
if (updateSuccess) {
|
||||||
|
updateSuccess()
|
||||||
|
this.$emit('onSaved', true)
|
||||||
|
this.$router.push({ name: 'SheetList' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.saving = false
|
this.saving = false
|
||||||
this.$emit('onSaved', true)
|
})
|
||||||
this.$router.push({ name: 'SheetList' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
sheetApi.create(this.selectedSheet, autoSave).then(response => {
|
sheetApi
|
||||||
this.$log.debug('Created sheet', response.data.data)
|
.create(this.selectedSheet, autoSave)
|
||||||
if (createSuccess) {
|
.then(response => {
|
||||||
createSuccess()
|
this.$log.debug('Created sheet', response.data.data)
|
||||||
|
if (createSuccess) {
|
||||||
|
createSuccess()
|
||||||
|
this.$emit('onSaved', true)
|
||||||
|
this.$router.push({ name: 'SheetList' })
|
||||||
|
}
|
||||||
|
this.selectedSheet = response.data.data
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.saving = false
|
this.saving = false
|
||||||
this.$emit('onSaved', true)
|
})
|
||||||
this.$router.push({ name: 'SheetList' })
|
|
||||||
}
|
|
||||||
this.selectedSheet = response.data.data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|
Loading…
Reference in New Issue