刷论坛时发现在楼主层回复的人id旁边也会有楼主标签
回复也带标识的问题可以通过加 :not(.embedded-reply) 的方式解决,比如这样
.topic-post.topic-owner article:not(#post_1) .topic-meta-data:not(.embedded-reply) .names::after
不过要单独标识回复里的楼主纯靠CSS应该是做不到了
谢谢您的方法,现在回复楼主的人不会被标记为楼主
细说细说 :bbb_000:zlb
如何收藏话题啊?我点了加入书签,但是好像在我后台没找到,点了置顶,但是置顶的优先级不高
大概实现就是在 post 组件上把主题创建者的 id 传给 embedded-post 组件,然后判断一下加个 topic-owner
修改了两个文件
app/assets/javascripts/discourse/app/widgets/post.js
总结
665行左右
post_number: attrs.post_number,
username: p.username,
}),
+ topicCreatedById: attrs.topicCreatedById
},
})
);
944行左右
createWidget("post-article", {
const replies = state.repliesAbove.map((p) => {
return this.attach("embedded-post", p, {
model: p.asPost,
- state: { above: true },
+ state: { above: true, topicCreatedById: attrs.topicCreatedById },
});
});
app/assets/javascripts/discourse/app/widgets/embedded-post.js
总结
43行左右
html(attrs, state) {
attrs.embeddedPost = true;
+ const isTopicOwner = attrs.user_id === state.topicCreatedById;
return [
h("div.row", [
this.attach("post-avatar", attrs),
h("div.topic-body", [
- h("div.topic-meta-data.embedded-reply", [
+ h("div.topic-meta-data.embedded-reply" + (isTopicOwner ? '.topic-owner' : ''), [
this.attach("poster-name", attrs),
this.attach("post-link-arrow", {
name: attrs.username,


