B-iggy
(B Iggy)
2021 年6 月 13 日 06:56
10
这是一个非常有用的组件!从用户体验的角度来看,它本应内置于 Discourse 中,但这只是我的个人意见。
不管怎样,我在尝试为“分类”实现相同的逻辑时遇到了困难。我本想使用 api.modifyClass 来完成,但似乎遗漏了关键部分。您能帮忙吗?
我的桌面页面有如下设置:
基本上,左侧的红框应该是可点击的:
或者,为了更直观地展示我想要实现的效果:复刻暴雪论坛的设计风格,因为我非常喜欢它:
非常感谢您的任何帮助。
B-iggy
(B Iggy)
2021 年6 月 16 日 12:37
11
很高兴你喜欢这个组件!
感谢你的建议
目前,该组件仅设计用于主题列表中的 Topics。
1 个赞
如果您想尝试并分叉此组件,我们非常欢迎!
作为让分类可点击的起点,建议您查看本组件中通过修改 Discourse 核心中的 topic-list-item 组件来实现该功能的代码。
import { withPluginApi } from "discourse/lib/plugin-api";
import { wantsNewWindow } from "discourse/lib/intercept-click";
export default {
name: "clickable-topic-list-item",
initialize() {
withPluginApi("0.8.14", api => {
api.modifyClass("component:topic-list-item", {
click(event) {
const result = this.showEntrance(event);
if (result === false) return result;
const topic = this.topic;
const target = $(event.target);
if (target.hasClass("bulk-select")) {
const selected = this.selected;
您可以尝试在同一文件夹中创建一个新文件,针对我们组件中包含的多种分类布局类型之一,并确保针对您在论坛上选择的相同分类页面样式。
以下是一些示例及其位置:
app/assets/javascripts/discourse/app/components/categories-and-latest-topics.js
app/assets/javascripts/discourse/app/components/categories-and-top-topics.js
app/assets/javascripts/discourse/app/components/categories-boxes-topic.js
app/assets/javascripts/discourse/app/components/categories-boxes-with-topics.js
app/assets/javascripts/discourse/app/components/categories-boxes.js
app/assets/javascripts/discourse/app/components/categories-only.js
app/assets/javascripts/discourse/app/components/category-list-item.js
3 个赞
现在已损坏。
我们曾依赖此组件来使“分类 + 最新 ”视图(在我们的情况下为默认视图)的主题卡片可点击。自今天更新到最新的 3.1.0beta8(现在显示为 3.2.0.beta1-dev)以来,该组件已停止正常工作。
现在光标的活动状态仍然是可点击的,但主题区域不可点击。打开浏览器的控制台会显示一个错误,这可能有助于开发人员识别问题:
未捕获的 TypeError: this.router is undefined
function navigateToTopic(topic, href) {
if (this.siteSettings.page_loading_indicator !== "slider") {
// With the slider, it feels nicer for the header to update once the rest of the topic content loads,
// so skip setting it early.
this.appEvents.trigger("header:update-topic", topic);
}
this.session.set("lastTopicIdViewed", {
topicId: topic.id,
historyUuid: this.router.location.getState?.().uuid
});
_url.default.routeTo(href || topic.get("url"));
return false;
}
抛出错误的行:
historyUuid: this.router.location.getState?.().uuid
这是否与核心中计划/正在进行的 Ember 升级有关?
We want to update the Ember version used in Discourse.
Right now, we’re on 3.15, and we’d like to get to 4.1
We’ve set a goal to finish this work by the end of this year. Please note that this topic is a roadmap, and all the plans and estimates are tentative. This topic is not intended to house any significant discussions about particular upgrades or changes. So, let’s keep the conversation here a bit focused. Questions about how these updates will affect your site/plugin/theme are off-topic. …
david
(David Taylor)
2023 年8 月 7 日 12:28
18
您好 @kinetiksoft - 我无法在我的端重现此问题。该主题组件似乎与最新版本的 Discourse 配合良好。此处 OP 中的“在主题创建者上预览”链接似乎也能正常工作。
您能否分享一个出现问题的网站链接?也许是与其他主题/插件发生了冲突。
2 个赞
谢谢!我已私信您一个相关社区的链接。不适合在此公开分享。
1 个赞
david
(David Taylor)
2023 年8 月 7 日 14:01
20
感谢 @kinetiksoft !看起来问题发生在当主题组件与“分类 + 最新”视图(您已将其配置为主页)一起使用时。
我已提交一个 PR,应该可以解决该问题。
main ← navigate-to-topic
opened 01:57PM - 07 Aug 23 UTC
This function was previously expecting multiple services to be injected on any c… lass that uses it. This kind of hidden requirement leads to some very difficult-to-debug situations, so this commit updates the function to lookup all its required services inline.
合并后我将在此处发布,然后您需要将论坛更新到最新版本的 Discourse 核心。
3 个赞
谢谢你,大卫!很高兴我们能帮助识别出完美运行组件中的问题。
2 个赞
david
(David Taylor)
2023 年8 月 7 日 15:56
22
David Taylor:
我会在合并后在此处发布
全部完成 - 因此,下次您更新到最新版本的 Discourse 时,它应该会生效
1 个赞
我们将在本周晚些时候进行更新尝试,我一定会回到这个话题来汇报一切进展情况。再次感谢!
1 个赞
我正在运行最新的 Discourse 3.4.0.beta2-dev。
我不确定是我对这个主题组件的设置有什么问题,还是其他原因,但卡片上主题的所有正文都无法点击。如果你点击文本末尾的任意一行,你就可以激活卡片并打开主题。
你认为可能是什么原因造成的?
提前感谢你的所有帮助和建议。
4 个赞
您好,感谢您的 TC,但似乎有一个区域仍然无法点击?
mcdanlj
(Michael K Johnson)
2025 年12 月 19 日 12:52
29
1 个赞