fix: 修复文章评论回复功能

This commit is contained in:
小莫唐尼 2024-06-27 00:21:26 +08:00
parent 4d0901b650
commit 77da85f7d4
5 changed files with 12 additions and 21 deletions

View File

@ -77,7 +77,7 @@ export default {
}, },
// 提交回复 // 提交回复
addPostCommentReply: (commentName, data) => { addPostCommentReply: (commentName, data) => {
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/replay`, data) return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, data)
}, },
/** /**

View File

@ -60,7 +60,7 @@ export default {
// 设置页面标题 // 设置页面标题
fnSetPageTitle(title) { fnSetPageTitle(title) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: title || (this.haloConfig && this.haloConfig.startConfig.title) || "uni-halo", title: title || this.haloConfig?.appConfig?.startConfig?.title || "uni-halo",
}) })
}, },

View File

@ -30,8 +30,7 @@
<text class="text-red text-size-s">- 文章已开启禁止评论 -</text> <text class="text-red text-size-s">- 文章已开启禁止评论 -</text>
</tm-empty> </tm-empty>
<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论"> <tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无评论">
<tm-button theme="light-blue" :dense="true" :shadow="0" size="m" <tm-button theme="light-blue" :dense="true" :shadow="0" size="m" @click="fnToComment(null)">抢沙发
@click="fnToComment(null)">抢沙发
</tm-button> </tm-button>
</tm-empty> </tm-empty>
</view> </view>
@ -146,11 +145,9 @@ export default {
return uni.$tm.toast('文章已禁止评论!'); return uni.$tm.toast('文章已禁止评论!');
} }
let _comment = {}; let _comment = {};
console.log('data', data)
if (data) { if (data) {
let { let {type, comment} = data;
type,
comment
} = data;
// //
_comment = { _comment = {
isComment: false, isComment: false,
@ -165,16 +162,14 @@ export default {
_comment = { _comment = {
isComment: true, isComment: true,
postName: this.post.metadata.name, postName: this.post.metadata.name,
title: '评论文章:' + this.post.spec.title, title: '新增评论',
formPage: 'comment_list', formPage: 'comment_list',
from: 'posts', from: 'posts',
type: 'post' type: 'post'
}; };
} }
this.$emit("on-comment", { this.$emit("on-comment", _comment)
_comment
})
}, },
fnCopyContent(content) { fnCopyContent(content) {
uni.$tm.u.setClipboardData(content); uni.$tm.u.setClipboardData(content);

View File

@ -169,7 +169,7 @@ export default {
} }
this.$httpApi.v2.addPostComment(commentForm) this.$httpApi.v2.addPostComment(commentForm)
.then(res => { .then(res => {
uni.$tm.toast('评论成功'); uni.$tm.toast('评论成功,可能需要审核');
// //
this.handleSetVisitor(); this.handleSetVisitor();
this.handleClose(true) this.handleClose(true)
@ -196,7 +196,7 @@ export default {
} }
this.$httpApi.v2.addPostCommentReply(this.form.postName, replyForm) this.$httpApi.v2.addPostCommentReply(this.form.postName, replyForm)
.then(res => { .then(res => {
uni.$tm.toast('回复成功'); uni.$tm.toast('回复成功,可能需要审核');
// //
this.handleSetVisitor(); this.handleSetVisitor();
this.handleClose(true) this.handleClose(true)

View File

@ -317,11 +317,7 @@ export default {
// = // =
originalURL() { originalURL() {
if ('unihalo_originalURL' in this.result?.metadata?.annotations) { return this.result?.metadata?.annotations?.unihalo_originalURL || ""
return this.result?.metadata?.annotations?.unihalo_originalURL;
} else {
return '';
}
}, },
calcIsShowComment() { calcIsShowComment() {
@ -445,12 +441,12 @@ export default {
} }
this.commentModal.isComment = true; this.commentModal.isComment = true;
this.commentModal.postName = this.result.metadata.name; this.commentModal.postName = this.result.metadata.name;
this.commentModal.title = this.result.spec.title; this.commentModal.title = "新增评论";
this.commentModal.show = true; this.commentModal.show = true;
}, },
fnOnComment(data) { fnOnComment(data) {
this.commentModal.isComment = data.isComment; this.commentModal.isComment = data.isComment;
this.commentModal.postName = data.name; this.commentModal.postName = data.postName;
this.commentModal.title = data.title; this.commentModal.title = data.title;
this.commentModal.show = true; this.commentModal.show = true;
}, },