未读主题 (手机版)

几天前,我的论坛出现了这个问题,尽管我已经进入了帖子,但它们对我来说仍然显示为未读。我在桌面版上也遇到了同样的问题,但设法在模板中解决了它。然而,说实话,我一直没能在移动版上解决这个问题。我希望有人能帮帮我,这是我使用的模板:

<script type='text/x-handlebars' data-template-name='mobile/list/topic-list-item.raw'>
    <td>
      {{#unless expandPinned}}
      <div class='pull-left'>
        <a href="/users/{{topic.creator.username}}">{{avatar topic.creator imageSize="50"}}</a>
              </div>
              
      <div class='right'>
      {{else}}
      <div>
            {{/unless~}}
            

<div class='main-link'>
          {{raw "topic-status" topic=topic}}
          {{topic-link topic}}
          {{#if topic.featured_link}}
            {{topic-featured-link topic}}
          {{/if}}
          
          
{{#if hideCategory}}
   <div class='category'>
          <span class="author-name"><a>{{topic.creator.username}}</a></span>
        </div>
{{else}}

{{/if}}
                    {{#if topic.unseen}}
                      <span class="badge-notification new-topic"></span>
                      
             {{/if}}
          {{~#if expandPinned}}
          {{raw "list/topic-excerpt" topic=topic}}
          {{/if~}}
        </div>
                <div class='pull-right'>
          {{raw "list/post-count-or-badges" topic=topic postBadgesEnabled=showTopicPostBadges}}
        </div>
    
        <div class="topic-item-stats clearfix">
          {{#unless hideCategory}}
            <div class='category'>
              {{category-link topic.category}}
            </div>
          {{/unless}}
    
          {{discourse-tags topic mode="list"}}
    
          <div class="pull-right">
            <div class='num activity last'>
            <span class="age activity" title="{{topic.bumpedAtTitle}}"><a>{{format-date topic.bumpedAt format="tiny" noTitle="true"}}</a></span>
            </div>
          </div>
              <div class="clearfix"></div>
        </div>
      </div>
    </td>
</script>

1 个赞

核心模板中有一些更改,因此您应该与它进行比较。

如果我没看错的话,您使用此 <a>用户/{{topic.creator.username}}</a>{{avatar topic.creator imageSize="50"}} 更改了个人资料头像部分,/users/ 路径是否正确?这将转到用户个人资料而不是打开用户卡。使用默认用户路径,它应该是 /u/

您模板中的另一个更改是,如果类别隐藏,则显示用户名。这在您的屏幕截图中非常明显。我像这样更改了该部分。

从您的模板中删除:

{{#if hideCategory}}
   <div>
          <span class="author-name"><a>{{topic.creator.username}}</a></span>
   </div>
{{else}}

{{/if}}

并添加到默认的 {{#unless hideCategory}}{{else}} 中。

{{#unless hideCategory}}
{{~raw-plugin-outlet name="topic-list-before-category"}}
<div class='category'>
  {{category-link topic.category}}
</div>
{{else}}
<span class="author-name">
  <a>{{topic.creator.username}}</a>
</span>
{{/unless}}

因此,我建议导入整个模板并根据您的需求进行修改,如下所示。

<script type='text/x-handlebars' data-template-name='mobile/list/topic-list-item.raw'>
<td class="topic-list-data">
  {{~raw-plugin-outlet name="topic-list-before-columns"}}
  <div class='pull-left'>
    <a href="/users/{{topic.creator.username}}">{{avatar topic.creator imageSize="50"}}</a>
  </div>
  <div class='right'>
    {{~raw-plugin-outlet name="topic-list-before-link"}}
    <div class='main-link'>
      {{~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 topic.unseen~}}
        <span class="topic-post-badges">&nbsp;<span class="badge-notification new-topic"></span></span>
      {{~/if~}}
      {{~#if expandPinned~}}
      {{~raw "list/topic-excerpt" topic=topic~}}
      {{~/if~}}
    </div>
    <div class='pull-right'>
      {{raw "list/post-count-or-badges" topic=topic postBadgesEnabled=showTopicPostBadges}}
    </div>
    <div class="topic-item-stats clearfix">
      {{#unless hideCategory}}
        {{~raw-plugin-outlet name="topic-list-before-category"}}
        <div class='category'>
          {{category-link topic.category}}
        </div>
        {{else}}
        <span class="author-name">
          <a>{{topic.creator.username}}</a>
        </span>
      {{/unless}}
      {{discourse-tags topic mode="list"}}
      <div class="pull-right">
        <div class='num activity last'>
          <span class="age activity" title="{{topic.bumpedAtTitle}}"><a>{{format-date topic.bumpedAt format="tiny" noTitle="true"}}</a>
          </span>
        </div>
      </div>
      <div class="clearfix"></div>
    </div>
  </div>
</td>
</script>

在我看来,这在主题创建者中看起来不错。如果我错过了什么,我很抱歉。


稍微修复一下 CSS,使标题内边距变薄,这样用户名就可以点击了。

.topic-list .main-link a.title {
  padding: 0.5em 0;
}
3 个赞

非常感谢,现在已经解决了,看起来很棒。:heart:

还有一件事,有什么 CSS 可以让作者名字的字体变大并着色吗?

1 个赞

很高兴它解决了。当然可以更改。像这样 :arrow_double_down:
您可以随意更改大小和颜色。

.topic-list .topic-item-stats .author-name a {
  font-size: var(--font-up-1);
  color: red;
}
2 个赞

再次非常感谢,它看起来正是我想要的。:heart:

Jennifer Lopez Reaction GIF by NBC World Of Dance

2 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.