# 精选徽章打破用户资料页面布局

**URL:** https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981
**Category:** General
**Created:** [2025年四月15日 21:32 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981 "2025-04-15T21:32:17Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月15日 21:32 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/1 "2025-04-15T21:32:17Z")

</div>

您好，

我注意到，用户资料页面在标题“特色徽章”之后就结束了。下面没有其他内容（尤其是没有保存按钮），除了网站的页脚。

在开发者控制台中发现了以下内容：

```plaintext
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split')
    at l.anonymous (user-featured-badges.js:12:1)
    at getter (index.js:444:104)
    at l.a [作为 featuredBadges] (cache-BESCGvbE.js:1878:17)
    at eM (cache-BESCGvbE.js:1647:18)
    at index.js:95:32
    at index.js:75:37
    at Z (index.js:418:5)
    at T (index.js:74:16)
    at eU (index-Cx6axmzR.js:1786:17)
    at eK.create (index-Cx6axmzR.js:1961:17)
    at Object.evaluate (index.js:1393:23)
    at Object.evaluate (index.js:770:198)
    at tq.evaluateSyscall (index.js:3353:20)
    at tq.evaluateInner (index.js:3332:60)
    at tq.evaluateOuter (index.js:3329:10)
    at t1.next (index.js:3990:46)
    at t1._execute (index.js:3979:21)
    at t1.execute (index.js:3955:41)
    at tW.handleException (index.js:3447:19)
    at tJ.handleException (index.js:3595:52)
    at t$.throw (index.js:3400:16)
    at ek.evaluate (index.js:964:42)
    at t$._execute (index.js:3387:34)
    at t$.execute (index.js:3379:17)
    at tQ.rerender (index.js:3613:8)
    at t5.render (index-Cx6axmzR.js:5114:55)
    at index-Cx6axmzR.js:5390:16
    at tD (index.js:2893:7)
    at io._renderRoots (index-Cx6axmzR.js:5370:7)
    at io._renderRootsTransaction (index-Cx6axmzR.js:5418:12)
    at io._revalidate (index-Cx6axmzR.js:5451:10)
    at invoke (index.js:262:14)
    at m.flush (index.js:180:11)
    at g.flush (index.js:334:19)
    at q._end (index.js:762:32)
    at index.js:499:12

```

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月16日 17:38 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/2 "2025-04-16T17:38:58Z")

</div>

关于这个问题有什么想法吗？我能提供什么信息来更好地调查这个问题？

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月16日 18:01 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/3 "2025-04-16T18:01:18Z")

</div>

…刚发现另一位设置了一些精选徽章的用户，其个人资料页面可以完全加载。我没有设置任何精选徽章——也许这就是原因？

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025年四月16日 18:40 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/4 "2025-04-16T18:40:15Z")

</div>

你试过安全模式吗？

我相信那一部分是由帖子徽章插件添加的，所以可能是插件中的一个错误，而不是核心Discourse的问题。

也许@Arkshine 了解更多这方面的信息

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2025年四月16日 19:25 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/5 "2025-04-16T19:25:32Z")

</div>

感谢您的反馈，@Roi，也感谢你，@Moin，把这个问题提出来了。我可以重现这个问题。当用户没有任何徽章时，就会出现这个问题。我会尽快提交一个PR。

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月16日 19:41 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/6 "2025-04-16T19:41:07Z")

</div>

谢谢！ 🙂

顺便问一下，我应该将它作为插件运行还是作为主题组件运行？

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2025年四月16日 20:08 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/7 "2025-04-16T20:08:36Z")

</div>

开始：

> <https://github.com/paviliondev/discourse-post-badges-plugin/pull/4>
>
> Meta: https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/3619…81
> 
> Followup #3.
> 
> This PR fixes an error that occurs when a user without badges visits their profile. The featured badges selector doesn't appear, and instead, it throws an error in the console. 
> 
> \`\`\`
> Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split')
> at l.\<anonymous\> (user-featured-badges.js:12:1)
> \`\`\`
> 
> Before: 
> !\[image\](https://github.com/user-attachments/assets/2725a729-eb7d-44a9-9ff1-2ffc5a7d3331)
> 
> After:
> !\[chrome\_ToPmxk9NCN\](https://github.com/user-attachments/assets/6351327a-4a48-4b6d-95cc-9f1cadcf98c5)

> [@Roi](#):
>
> 顺便说一句，我将此作为插件运行。这是正确的还是我应该将其作为主题组件运行？

主题组件版本不允许用户在个人资料中选择徽章。它是所有用户的全局设置，这是主要区别。

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月16日 20:10 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/8 "2025-04-16T20:10:39Z")

</div>

所以我的理解是插件版本更好？

感谢您的 PR！ 🙂 这两个版本都适用吗？

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2025年四月16日 20:21 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/9 "2025-04-16T20:21:59Z")

</div>

> [@Roi](#):
>
> 所以我的理解是插件版本更好？

这取决于您是想让用户控制他们想显示哪些徽章（插件），还是让管理员根据用户当前的徽章来控制允许显示哪些徽章（TC）。

TC 在功能上无法实现与插件相同的功能，但我认为这两种方式都有其用途，具体取决于您的需求。

---

<div class="post-metadata">

### Author: ![Roi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roi/32/130587_2.png) [@Roi](https://meta.discourse.org/u/Roi)
#### Post date: [2025年四月18日 11:23 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/10 "2025-04-18T11:23:31Z")

</div>

> [@Arkshine](#):
>
> 开始了

PR 已合并，现在可以正常工作了，再次感谢！ 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2025年四月22日 07:20 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/11 "2025-04-22T07:20:59Z")

</div>

注意：第三方主题/组件或插件的 bug 跟踪应在专门的插件/主题/组件主题或第三方 bug 跟踪器中进行。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2025年四月22日 07:21 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/12 "2025-04-22T07:21:24Z")

</div>



---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025年四月23日 23:26 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/13 "2025-04-23T23:26:09Z")

</div>



---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [2025年四月23日 23:27 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/14 "2025-04-23T23:27:41Z")

</div>

@Arkshine 你能分享关于受影响主题组件的元话题的链接吗？我会把这些内容都移到那里，并整理这些管理方面的帖子。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2025年四月23日 23:48 UTC](https://meta.discourse.org/t/featured-badges-breaks-user-profile-page/361981/15 "2025-04-23T23:48:37Z")

</div>

这是一个插件，据我所知，没有相关主题。Angus 最初将其发布在官方 TC 主题中：[Post Badges - #121 by angus](https://meta.discourse.org/t/post-badges/114722/121?u=arkshine%E3%80%82) 🤔
