# Development

**URL:** https://meta.discourse.org/c/dev/7.md?page=43

[最新版本](https://meta.discourse.org/latest.md) · [分類](https://meta.discourse.org/categories.md) · [標簽](https://meta.discourse.org/tags.md)

**Page:** 44

---

## [如何才能在每个页面“加载”时触发我的自定义统计脚本？](https://meta.discourse.org/t/how-can-i-trigger-my-custom-statistics-script-on-every-page-load/274026)

<div class="topic-metadata">

**Author:** [@nodomain](https://meta.discourse.org/u/nodomain)\
**回覆:** 2\
**Last updated:** [2023年八月5日 07:52 UTC](https://meta.discourse.org/t/how-can-i-trigger-my-custom-statistics-script-on-every-page-load/274026 "2023-08-05T07:52:53Z")

</div>

考虑到 Discourse 是一个 SPA，并且查阅了关于此主题的一些文档，我仍然不确定如何实现这一点：我们在页脚包含了一个自定义的 JS 库，该库可与我们的统计解决方案进行交互，我们希望...

---

## [以编程方式自定义侧边栏](https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027)

<div class="topic-metadata">

**Author:** [@literarymachine](https://meta.discourse.org/u/literarymachine)\
**回覆:** 5\
**Last updated:** [2023年八月4日 01:43 UTC](https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027 "2023-08-04T01:43:14Z")

</div>

这是一个很棒的功能，但是，自定义侧边栏部分的内容是否需要以编程方式创建？我已经通过一种类似于上面 @Olya\_Fursova 的方式实现了这一点，只是内容是通过 quer… 生成的

---

## [使用API创建帖子投票主题](https://meta.discourse.org/t/creating-post-voting-topics-with-the-api/273787)

<div class="topic-metadata">

**Author:** [@kuaza](https://meta.discourse.org/u/kuaza)\
**回覆:** 2\
**Last updated:** [2023年八月3日 14:53 UTC](https://meta.discourse.org/t/creating-post-voting-topics-with-the-api/273787 "2023-08-03T14:53:35Z")

</div>

https://docs.discourse.org/#tag/Posts/operation/createTopicPostPM 当我们使用API创建新主题时，主题会正常创建，即使我们在类别中进行了设置。我正在使用API工作，如何...

---

## [更改 UserMenu 默认标签](https://meta.discourse.org/t/change-the-usermenu-default-tab/273818)

<div class="topic-metadata">

**Author:** [@zcuric](https://meta.discourse.org/u/zcuric)\
**回覆:** 0\
**Last updated:** [2023年八月3日 12:51 UTC](https://meta.discourse.org/t/change-the-usermenu-default-tab/273818 "2023-08-03T12:51:42Z")

</div>

我很久没有处理过 Discourse 主题了，上次我做插件 API (v0.8) 时，启用了将默认的快速访问选项卡设置为如下方式： api.reopenWidget("user-menu", { defaultState() { …

---

## [自动打开登录弹窗](https://meta.discourse.org/t/open-the-login-modal-automatically/273671)

<div class="topic-metadata">

**Author:** [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)\
**回覆:** 0\
**Last updated:** [2023年八月2日 15:28 UTC](https://meta.discourse.org/t/open-the-login-modal-automatically/273671 "2023-08-02T15:28:08Z")

</div>

接续关于“访问网站时立即打开登录弹出窗口”的讨论： 我修改了@Don的主题组件，使其自动打开“登录”模态框，而不是“创建账户”模态框。万一某些…

---

## [sidebarMod: 增删侧边栏链接和部分](https://meta.discourse.org/t/sidebarmod-add-remove-sidebar-links-and-sections/261279)

<div class="topic-metadata">

**Author:** [@shyguy](https://meta.discourse.org/u/shyguy)\
**回覆:** 3\
**Last updated:** [2023年八月2日 14:38 UTC](https://meta.discourse.org/t/sidebarmod-add-remove-sidebar-links-and-sections/261279 "2023-08-02T14:38:56Z")

</div>

sidebarMod 这是我用于修改侧边栏的脚本（首次在自定义侧边栏部分主题中提及）。它使用 promises 和 MutationObserver 来监视侧边栏的变化（例如，展开或折叠时）以及……

---

## [重新排列侧边栏顺序？](https://meta.discourse.org/t/rearrange-sidebar-order/273405)

<div class="topic-metadata">

**Author:** [@discoursejl](https://meta.discourse.org/u/discoursejl)\
**回覆:** 2\
**Last updated:** [2023年七月31日 23:23 UTC](https://meta.discourse.org/t/rearrange-sidebar-order/273405 "2023-07-31T23:23:07Z")

</div>

能否调整侧边栏？ 例如，将“频道”移动到“类别”上方？

---

## [帮助替换图标](https://meta.discourse.org/t/help-replacing-an-icon/273277)

<div class="topic-metadata">

**Author:** [@davidkingham](https://meta.discourse.org/u/davidkingham)\
**回覆:** 10\
**Last updated:** [2023年七月31日 17:19 UTC](https://meta.discourse.org/t/help-replacing-an-icon/273277 "2023-07-31T17:19:43Z")

</div>

我正在尝试替换用于打开/关闭侧边栏的条形图标，遵循以下说明：在主题中用自定义图标替换 Discourse 的默认 SVG 图标，但我不太走运。我创建了一个 spriteshe…

---

## [更改默认徽章颜色（青铜、银色、金色）](https://meta.discourse.org/t/change-default-badge-colors-bronze-silver-gold/273245)

<div class="topic-metadata">

**Author:** [@discoursejl](https://meta.discourse.org/u/discoursejl)\
**回覆:** 7\
**Last updated:** [2023年七月31日 12:41 UTC](https://meta.discourse.org/t/change-default-badge-colors-bronze-silver-gold/273245 "2023-07-31T12:41:09Z")

</div>

是否可以将徽章的颜色从金色、银色和青铜色更改为三种更符合我们主题颜色的颜色？希望将它们更改得更协调一些。

---

## [通过 SCSS @each 规则访问主题列表设置](https://meta.discourse.org/t/accessing-theme-list-settings-via-scss-each-rule/272142)

<div class="topic-metadata">

**Author:** [@Lilly](https://meta.discourse.org/u/Lilly)\
**回覆:** 4\
**Last updated:** [2023年七月31日 11:38 UTC](https://meta.discourse.org/t/accessing-theme-list-settings-via-scss-each-rule/272142 "2023-07-31T11:38:49Z")

</div>

我正在尝试使用 SCSS 的 @each 操作符来访问 yml 文件中的列表设置，但它无法处理一个以上的列表项。当列表为空（默认值“”）或只有一个项时，代码按预期工作，但当列表项多于一个时则不行。sett…

---

## [对原始模板进行自定义更改](https://meta.discourse.org/t/making-custom-changes-to-a-raw-template/273004)

<div class="topic-metadata">

**Author:** [@boltronics](https://meta.discourse.org/u/boltronics)\
**回覆:** 5\
**Last updated:** [2023年七月27日 23:53 UTC](https://meta.discourse.org/t/making-custom-changes-to-a-raw-template/273004 "2023-07-27T23:53:55Z")

</div>

在我们的主题列表页面上，会显示每个主题的主要参与者的头像，以及指向用户个人资料页面的链接。 您可以在此处看到： 当用户未登录时，此链接将不会显示……

---

## [如何添加我自己的下拉菜单(popupMenu)，像编写器选项那样？](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314)

<div class="topic-metadata">

**Author:** [@tyler-mairose-sp](https://meta.discourse.org/u/tyler-mairose-sp)\
**回覆:** 4\
**Last updated:** [2023年七月27日 20:02 UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314 "2023-07-27T20:02:29Z")

</div>

我将以下代码添加到了我的主题组件，并期望在编辑器中出现一个新的弹出菜单。 api.onToolbarCreate(toolbar =\> { toolbar.addButton({ id: "align\_center\_button", group: "crud", …

---

## [无法启动开发实例-- renice：设置优先级失败](https://meta.discourse.org/t/cant-start-development-instance-renice-failed-to-set-priority/265375)

<div class="topic-metadata">

**Author:** [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**回覆:** 5\
**Last updated:** [2023年七月27日 13:07 UTC](https://meta.discourse.org/t/cant-start-development-instance-renice-failed-to-set-priority/265375 "2023-07-27T13:07:34Z")

</div>

我不知道自上次启动这个开发实例以来发生了什么变化，但现在它失败成这样了： Sidekiq 客户端使用 Sidekiq::RedisConnection::RedisAdapter 选项 {:host=\>"localhost", :port=\>637...

---

## [插件API中更灵活的高亮配置？](https://meta.discourse.org/t/more-flexible-highlight-configuration-in-plugin-api/272879)

<div class="topic-metadata">

**Author:** [@hawm](https://meta.discourse.org/u/hawm)\
**回覆:** 1\
**Last updated:** [2023年七月26日 15:03 UTC](https://meta.discourse.org/t/more-flexible-highlight-configuration-in-plugin-api/272879 "2023-07-26T15:03:59Z")

</div>

为了支持自定义 HTML 高亮和可配置的 highlightjs 全局选项，似乎需要一些额外的插件 API。 这个 PR 是否受欢迎？我已经在我的 fork 仓库中做了一些工作。

---

## [主题样式表：在不同文件夹中无法使用相同的文件名.scss](https://meta.discourse.org/t/theme-stylesheets-cant-use-the-same-filename-scss-in-different-folders/272563)

<div class="topic-metadata">

**Author:** [@manuel](https://meta.discourse.org/u/manuel)\
**回覆:** 1\
**Last updated:** [2023年七月26日 10:03 UTC](https://meta.discourse.org/t/theme-stylesheets-cant-use-the-same-filename-scss-in-different-folders/272563 "2023-07-26T10:03:52Z")

</div>

例如： 我有一个类似这样的结构： stylesheets desktop footer.scss mobile footer.scss mobile文件夹中的文件未被识别。我必须给它起一个不同的名字。这可以被改变吗，还是它是…的一部分

---

## [我想在主题答案之间插入图片（横幅）。我该如何开始？](https://meta.discourse.org/t/i-want-to-insert-images-banner-between-the-topic-answers-how-do-i-start/272783)

<div class="topic-metadata">

**Author:** [@tullsman](https://meta.discourse.org/u/tullsman)\
**回覆:** 7\
**Last updated:** [2023年七月25日 18:49 UTC](https://meta.discourse.org/t/i-want-to-insert-images-banner-between-the-topic-answers-how-do-i-start/272783 "2023-07-25T18:49:04Z")

</div>

你好。我想在主题的答案之间插入图片（横幅）。 我该如何开始？在哪里可以打开我的主题文件，以及在哪个文件中插入图片的代码/链接？ 谢谢。

---

## [为移动端 topic-post 设置了最小高度的内联样式](https://meta.discourse.org/t/inline-styles-of-minimal-height-declared-for-topic-post-on-mobile/272566)

<div class="topic-metadata">

**Author:** [@manuel](https://meta.discourse.org/u/manuel)\
**回覆:** 2\
**Last updated:** [2023年七月25日 16:32 UTC](https://meta.discourse.org/t/inline-styles-of-minimal-height-declared-for-topic-post-on-mobile/272566 "2023-07-25T16:32:41Z")

</div>

我有一个主题，可以稍微改变移动设备上的帖子视图。 现在我看到布局被 \`min-height\` 声明弄乱了，这些声明在滚动时被计算并作为内联样式注入： 例如，这里的帖子……

---

## [分类和标签面包屑导航下拉菜单定位问题](https://meta.discourse.org/t/category-tag-breadcrumbs-dropdown-positioning-issue/272779)

<div class="topic-metadata">

**Author:** [@Decrypt](https://meta.discourse.org/u/Decrypt)\
**回覆:** 2\
**Last updated:** [2023年七月25日 15:24 UTC](https://meta.discourse.org/t/category-tag-breadcrumbs-dropdown-positioning-issue/272779 "2023-07-25T15:24:49Z")

</div>

你好！我正在尝试创建一个自定义主题，所以我 fork 了一个“air theme”并做了一些修改，但我注意到分类和标签的下拉菜单位置很奇怪。 你知道什么原因吗……

---

## [如果您想编辑此主题，则必须在其仓库中提交更改。](https://meta.discourse.org/t/if-you-want-to-edit-this-theme-you-must-submit-a-change-on-its-repository/272664)

<div class="topic-metadata">

**Author:** [@resakdo22](https://meta.discourse.org/u/resakdo22)\
**回覆:** 3\
**Last updated:** [2023年七月24日 18:29 UTC](https://meta.discourse.org/t/if-you-want-to-edit-this-theme-you-must-submit-a-change-on-its-repository/272664 "2023-07-24T18:29:18Z")

</div>

大家好！ 我在本地的 Discourse 实例中分叉了我雇主的一个主题存储库，然后我收到一条消息，说我需要提交一个更改才能编辑该主题。 我提交了各种 sm…

---

## [侧边栏上的新闻和相关信息](https://meta.discourse.org/t/news-on-the-sidebar/271396)

<div class="topic-metadata">

**Author:** [@fuchs](https://meta.discourse.org/u/fuchs)\
**回覆:** 8\
**Last updated:** [2023年七月24日 13:02 UTC](https://meta.discourse.org/t/news-on-the-sidebar/271396 "2023-07-24T13:02:32Z")

</div>

是否可以制作一个侧边栏滑块，其中包含来自“news”标签的最新新闻，附带图片、标题和简短描述？

---

## [从聊天区域隐藏我添加的页眉代码](https://meta.discourse.org/t/hiding-the-header-code-i-added-from-the-chat-area/272546)

<div class="topic-metadata">

**Author:** [@vifyirusti](https://meta.discourse.org/u/vifyirusti)\
**回覆:** 3\
**Last updated:** [2023年七月23日 15:11 UTC](https://meta.discourse.org/t/hiding-the-header-code-i-added-from-the-chat-area/272546 "2023-07-23T15:11:23Z")

</div>

亲爱的朋友们，大家好。 我在标题中添加了一段代码，运行效果很好。 我添加的代码是； div class=“block22” button class=“block22” Block Button button div 但是我想在手机的聊天页面上隐藏这个项目……

---

## [能用API将帖子转换为帖子操作吗？](https://meta.discourse.org/t/can-a-post-be-converted-into-a-post-action-using-the-api/272464)

<div class="topic-metadata">

**Author:** [@hello-smile6](https://meta.discourse.org/u/hello-smile6)\
**回覆:** 2\
**Last updated:** [2023年七月21日 22:10 UTC](https://meta.discourse.org/t/can-a-post-be-converted-into-a-post-action-using-the-api/272464 "2023-07-21T22:10:05Z")

</div>

我知道可以将普通帖子转换为耳语（反之亦然），但可以将普通帖子转换为帖子操作吗？

---

## [自定义 javascript 和 canvas 元素](https://meta.discourse.org/t/custom-javascript-and-canvas-element/272444)

<div class="topic-metadata">

**Author:** [@ols](https://meta.discourse.org/u/ols)\
**回覆:** 0\
**Last updated:** [2023年七月21日 20:02 UTC](https://meta.discourse.org/t/custom-javascript-and-canvas-element/272444 "2023-07-21T20:02:42Z")

</div>

基本问题： 是否可以将自定义 JavaScript 代码添加到页面/主题中？ 例如，如果我想要一个 200x200 的 canvas 元素，并能够用 vanilla js、ctx.lineTo() 等在其上绘制线条， 我看到过这个……

---

## [我能将这个插件集成到我的React Native应用程序吗？](https://meta.discourse.org/t/can-i-integrate-this-plugin-into-my-react-native-application/272400)

<div class="topic-metadata">

**Author:** [@Thien\_Nguyen\_Ngoc](https://meta.discourse.org/u/Thien_Nguyen_Ngoc)\
**回覆:** 2\
**Last updated:** [2023年七月21日 17:18 UTC](https://meta.discourse.org/t/can-i-integrate-this-plugin-into-my-react-native-application/272400 "2023-07-21T17:18:39Z")

</div>

我可以将这个插件集成到我的 React Native 应用中吗？我尝试查找相关文档，但没找到😞。希望你们能帮帮我。

---

## [用于在单个请求中接收任意帖子数组的.json端点](https://meta.discourse.org/t/json-endpoint-to-receive-array-of-arbitrary-posts-with-a-single-request/272127)

<div class="topic-metadata">

**Author:** [@pipkin](https://meta.discourse.org/u/pipkin)\
**回覆:** 5\
**Last updated:** [2023年七月19日 21:23 UTC](https://meta.discourse.org/t/json-endpoint-to-receive-array-of-arbitrary-posts-with-a-single-request/272127 "2023-07-19T21:23:44Z")

</div>

你好， 是否有任何.json端点允许我按ID请求任意数量的帖子？我指的是帖子，不是主题。 例如 posts.json?id=2,9,40,388,... 等等。 我一直在查看代码，但是...

---

## [如何更改没有选择器的 span 元素的文本？](https://meta.discourse.org/t/how-to-change-text-of-this-span-object-with-no-selectors/272016)

<div class="topic-metadata">

**Author:** [@jordan-violet](https://meta.discourse.org/u/jordan-violet)\
**回覆:** 6\
**Last updated:** [2023年七月19日 12:05 UTC](https://meta.discourse.org/t/how-to-change-text-of-this-span-object-with-no-selectors/272016 "2023-07-19T12:05:24Z")

</div>

此对象具有以下 HTML：

---

## [移动移动子类别？](https://meta.discourse.org/t/moving-mobile-subcategories/271818)

<div class="topic-metadata">

**Author:** [@TheDarkWizard](https://meta.discourse.org/u/TheDarkWizard)\
**回覆:** 2\
**Last updated:** [2023年七月18日 11:17 UTC](https://meta.discourse.org/t/moving-mobile-subcategories/271818 "2023-07-18T11:17:21Z")

</div>

大家好， 在过去的几周里，我一直在学习如何进行主题化以及使用主题，因为我们正处于迁移的那个阶段，或者说，我们已经准备好几乎只专注于此。 我做了一些很棒的……

---

## [将现有数据库集成到 Discourse](https://meta.discourse.org/t/integrate-an-existing-database-to-discourse/271809)

<div class="topic-metadata">

**Author:** [@what](https://meta.discourse.org/u/what)\
**回覆:** 3\
**Last updated:** [2023年七月17日 22:21 UTC](https://meta.discourse.org/t/integrate-an-existing-database-to-discourse/271809 "2023-07-17T22:21:12Z")

</div>

是否可以为另一个数据库提供一个API，该数据库拥有自己的主题、帖子、搜索功能，并将其集成到Discourse中，以便我可以使用Discourse作为前端，而将该数据库作为后端？

---

## [Command line restore for web only container can't load thor](https://meta.discourse.org/t/command-line-restore-for-web-only-container-cant-load-thor/68570)

<div class="topic-metadata">

**Author:** [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**回覆:** 10\
**Last updated:** [2023年七月17日 17:00 UTC](https://meta.discourse.org/t/command-line-restore-for-web-only-container-cant-load-thor/68570 "2023-07-17T17:00:19Z")

</div>

I just tried to do a restore on a web\_only container and it whines that it can’t load thor when it tries to load\_rails. (If you don’t actually try to restore, it doesn’t fail --and OMG, how awesome is it that it suggest…

---

## [分类中主题列表顶部的标签](https://meta.discourse.org/t/tags-at-the-top-of-the-topic-list-in-a-category/271586)

<div class="topic-metadata">

**Author:** [@TheDarkWizard](https://meta.discourse.org/u/TheDarkWizard)\
**回覆:** 2\
**Last updated:** [2023年七月17日 16:54 UTC](https://meta.discourse.org/t/tags-at-the-top-of-the-topic-list-in-a-category/271586 "2023-07-17T16:54:30Z")

</div>

大家好， 我通过使用模板、插件出口以及Discourse中所有神奇的功能学到了很多东西。是否可以在主题列表的顶部列出该类别中使用的所有标签？

[上一頁](https://meta.discourse.org/c/dev/7.md?page=42)

[下一頁](https://meta.discourse.org/c/dev/7.md?page=44)
