diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 6d1ab1d..3e03fc9 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -467,21 +467,35 @@ export default { return } - const { data } = await this.$axios.post('/comments/commit', { - postID, - lastID, - parentID, - content: type === 'editor-reply' ? window.editorReplyObj.getValue() : window.editorObj.getValue() + const editorObj = type === 'editor-reply' ? window.editorReplyObj : window.editorObj + + const { data } = await this.$axios({ + method: 'post', + url: process.env.baseURL + '/comments/commit', + headers: { + Authorization: 'Bearer ' + window.localStorage.visitorToken + }, + data: { + postID, + lastID, + parentID, + content: editorObj.getValue() + } }) if (data.status === 1) { // 获取评论 - const tmp = await this.$axios.get(`/public/comments/post?ID=${postID}`) - const comments = tmp.result.list || [] - const commentAmount = tmp.result.amount || 0 + const tmp = await this.$axios.get(process.env.baseURL + `/public/comments/post?ID=${postID}`) + const comments = tmp.data.result.list || [] + const commentAmount = tmp.data.result.amount || 0 this.comments = comments this.commentAmount = commentAmount this.setCommentMap() + editorObj.setValue('', true) + this.$nextTick(() => { + editorObj.focus() + editorObj.insertValue('', true) + }) } }, commentLogout () {