Steven
23
您可以直接编辑该组件,修改头部部分并粘贴此内容。它将使用旧版本
<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
{{#if bulkSelectEnabled}}
<td class="bulk-select">
<input type="checkbox" class="bulk-select">
</td>
{{/if}}
<td class='main-link clearfix' colspan="1">
<span class='link-top-line'>
{{~raw-plugin-outlet name="topic-list-before-status"}}
{{~raw "topic-status" topic=topic}}
{{~topic-link topic class="raw-link raw-topic-link"}}
{{~#if topic.featured_link}}
{{~topic-featured-link topic}}
{{~/if}}
{{~raw-plugin-outlet name="topic-list-after-title"}}
{{~#if showTopicPostBadges}}
{{~raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~/if}}
</span>
<div class="link-bottom-line">
{{#unless hideCategory}}
{{#unless topic.isPinnedUncategorized}}
{{category-link topic.category}}
{{/unless}}
{{/unless}}
<span class='topic-creator'>{{d-icon "user"}} <a href="/users/{{topic.creator.username}}" data-auto-route="true" data-user-card="{{topic.creator.username}}">{{topic.creator.username}}</a></span>
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</div>
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
</td>
{{raw "list/posts-count-column" topic=topic}}
{{#if showLikes}}
<td class="num likes">
{{#if hasLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} {{d-icon "heart"}}</td>
</a>
{{/if}}
{{/if}}
{{#if showOpLikes}}
<td class="num likes">
{{#if hasOpLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.op_like_count}} {{d-icon "heart"}}</td>
</a>
{{/if}}
{{/if}}
<td class="num views {{topic.viewsHeat}}">{{number topic.views numberKey="views_long"}}</td>
<td class="last-post">
<div class='poster-avatar'>
<a href="{{topic.lastPostUr}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPoster usernamePath="username" imageSize="medium"}}</a>
</div>
<div class='poster-info'>
<span class='editor'><a href="/users/{{topic.last_poster_username}}" data-auto-route="true" data-user-card="{{topic.last_poster_username}}">{{topic.last_poster_username}}</a></span>
<br />
<a href="{{topic.lastPostUrl}}">
{{format-date topic.bumpedAt format="tiny"}}
</a>
</div>
</td>
</script>
<script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
{{#if bulkSelectEnabled}}
<th class="bulk-select">
{{#if canBulkSelect}}
{{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
{{/if}}
</th>
{{/if}}
{{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies'}}
{{#if showLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes'}}
{{/if}}
{{#if showOpLikes}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes'}}
{{/if}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='views' name='views'}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity'}}
</script>
<script>
(function(){
var TopicListItemView = require('discourse/components/topic-list-item').default;
TopicListItemView.reopen({
showCategory: function(){
return !this.get('controller.hideCategory') &&
this.get('topic.creator') &&
this.get('topic.category.name') !== 'uncategorized';
}.property()
});
})();
</script>
3 个赞
Steven
25
我为那些不想编辑组件且暂时无法升级 Discourse 论坛的用户创建了一个特定分支。
您可以安装新组件,并使用高级设置。
包含主题的仓库:https://github.com/iunctis/md-topic-list
分支名称:bf-20200323
您将获得与 2020 年 3 月 23 日之前版本的 Discourse 兼容的组件。该版本在 此提交 之前。
2 个赞
Steven
26
我在移动端稍微尝试了一下主题列表的展示方式,虽然还需要进一步完善,但你们会对类似这样的设计感兴趣吗(这将是一个独立的组件):
当前的移动端主题列表展示:
头像仍然会打开用户卡片,日期则链接到最新回复。
6 个赞
我肯定会,这将会是一个很好的补充,尤其是因为移动端和桌面的布局会相似,而不是看起来完全不同:slight_smile:
jrgong
(jrgong)
28
预览链接无法工作。当我尝试访问时,收到以下错误消息:
访问被拒绝
在尝试加载 /theme/Steven/md-topic-list.json 时
出错了。
1 个赞
Steven
29
抱歉,我之前清理了 Discourse 主题页面,但清理得有点过头了:扫帚
现在应该已经修复了,感谢反馈!
2 个赞
jrgong
(jrgong)
30
嘿 @Steven
我已经是 2.4.1 版本了,但我的头像仍然不见了。请看我的主题预览截图:
你试过这个分支吗?
如果你的 Discourse 版本早于 3 月 23 日,在升级论坛之前,你需要使用这个分支:
[quote=“Steven, post:25, topic:117694, full:true”]
我为那些不想修改组件且暂时无法升级 Discourse 论坛的用户创建了一个专用分支。
你可以安装一个新的组件,并使用高级设置。
包含主题的仓库:https://github.com/iunctis/md-topic-list
分支名称:bf-20200323
你将获得与 2020 年 3 月 23 日之前的 Discourse 版本兼容的组件。在此之前 此提交 之前。[/quote]
1 个赞
jrgong
(jrgong)
32
有人在使用这个主题组件的同时搭配“话题列表预览”插件吗?还是说它终究会导致问题?
我目前使用的是 Sam 的极简主题,但它与当前版本的“话题列表预览”插件不兼容。因此,我正在考虑更换主题,以便能够同时实现极简风格的话题列表和话题图片预览功能。
Steven
33
Steven
34
我刚刚进行了一次小幅升级。虽然没有新功能,但我增加了对新缩略图函数的兼容性。
该主题组件与以下组件兼容:
4 个赞
nory
35
很遗憾不行,因为我们编辑的是同一个文件。
如果你修改头部代码,并将瓦片样式与我的修改整合起来,可以让两者都生效,但这需要你对工作原理有一定的了解。
你可以从我旧版自定义的主题列表预览中获取一些灵感(那是在官方缩略图主题组件发布之前,所以目前可能无法使用):https://github.com/iunctis/discourse-topic-previews/blob/master/assets/javascripts/discourse/templates/list/topic-list-item.hbr
不过,它对某些元素使用了不同的 CSS 类和排列方式,这可能不适用于你的论坛。
2 个赞
pinder99
(Raza shield)
37
嗨 @Steven,我一直在使用你的插件。我移除了话题中的“活动”标签和“查看”标签,想把它们移到话题下方,就像你的插件那样,但一直没成功。你能帮帮我吗?我只想添加一个日期(活动),就像下面的图片一样:

Steven
38
首先,您需要更改表格结构,并删除“视图”和“活动”列:
<script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
{{#if bulkSelectEnabled}}
<th class="bulk-select">
{{#if canBulkSelect}}
{{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
{{/if}}
</th>
{{/if}}
{{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect}}
{{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies'}}
</script>
如果您也想删除“回复”列,可以顺便删除最后一行。
接下来处理内容部分。首先,我已删除了上述两列:
<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
{{~raw-plugin-outlet name="topic-list-before-columns"}}
{{#if bulkSelectEnabled}}
<td class="bulk-select">
<input type="checkbox" class="bulk-select">
</td>
{{/if}}
<td class='main-link clearfix' colspan="1">
{{~raw-plugin-outlet name="topic-list-before-link"}}
<span class='link-top-line'>
{{~raw-plugin-outlet name="topic-list-before-status"}}
{{~raw "topic-status" topic=topic}}
{{~topic-link topic class="raw-link raw-topic-link"}}
{{~#if topic.featured_link}}
{{~topic-featured-link topic}}
{{~/if}}
{{~raw-plugin-outlet name="topic-list-after-title"}}
{{~raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
topicId=topic.id
unreadClass=unreadClass~}}
{{~#if showTopicPostBadges}}
{{~raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~/if}}
</span>
<div class="link-bottom-line">
{{#unless hideCategory}}
{{#unless topic.isPinnedUncategorized}}
{{category-link topic.category}}
{{/unless}}
{{/unless}}
<span class='topic-creator'>{{d-icon "user"}} <a href="/users/{{topic.creator.username}}" data-auto-route="true" data-user-card="{{topic.creator.username}}">{{topic.creator.username}}</a></span>
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</div>
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
</td>
{{raw "list/posts-count-column" topic=topic}}
</script>
接下来,我们添加所需的内容。由于需要一些额外工作,我不会列出所有细节,但整体结构应如下所示:
<script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
{{~raw-plugin-outlet name="topic-list-before-columns"}}
{{#if bulkSelectEnabled}}
<td class="bulk-select">
<input type="checkbox" class="bulk-select">
</td>
{{/if}}
<td class='main-link clearfix' colspan="1">
{{~raw-plugin-outlet name="topic-list-before-link"}}
<span class='link-top-line'>
{{~raw-plugin-outlet name="topic-list-before-status"}}
{{~raw "topic-status" topic=topic}}
{{~topic-link topic class="raw-link raw-topic-link"}}
{{~#if topic.featured_link}}
{{~topic-featured-link topic}}
{{~/if}}
{{~raw-plugin-outlet name="topic-list-after-title"}}
{{~raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
topicId=topic.id
unreadClass=unreadClass~}}
{{~#if showTopicPostBadges}}
{{~raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~/if}}
</span>
<div class="link-bottom-line">
{{#unless hideCategory}}
{{#unless topic.isPinnedUncategorized}}
{{category-link topic.category}}
{{/unless}}
{{/unless}}
<span>Started <a href={{topic.url}}>{{format-date topic.createdAt format="tiny"}}</a> by <a href="/users/{{topic.creator.username}}" data-auto-route="true" data-user-card="{{topic.creator.username}}">{{topic.creator.username}}</a></span><br>
<span><a href="{{topic.lastPostUrl}}">Last post {{format-date topic.bumpedAt format="tiny"}}</a> by <a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}">{{topic.last_poster_username}}</a></span>
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</div>
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
</td>
{{raw "list/posts-count-column" topic=topic}}
</script>
这只是一个初步草稿,我尚未进行测试。您可能需要添加一些 <span> 类,或调整日期格式(例如将 format="tiny" 改为 format="medium"),但整体结构应该基本没问题。
1 个赞
pinder99
(Raza shield)
39
真的非常感谢你 @Steven,这确实是我需要的,非常感激你的快速回复。还有一件事,“admin”和“最后发帖”之间没有间距,如何给它们添加一些空格?

Steven
40
我添加了一个 <br>,奇怪的是它没生效。如果你不习惯在 span 标签中添加 class 元素,可以把它放在 span 标签里,或者使用 来强制增加一些间距。
1 个赞
pinder99
(Raza shield)
42
@Steven 它在桌面端运行正常(还添加了一些数据),但在移动版本上不显示,你能帮忙看看吗?