所以我已经知道 /my/billing/subscriptions 是链接当前用户到其个人资料(特别是 Discourse Subscriptions 附带的账单部分)的一种方式。然而,这在我下面的代码中似乎不起作用,尤其是在 if 语句中的表达式部分。具体来说,我试图让一个按钮仅在用户的账单页面上显示。事实上,它似乎对任何以 /my 开头的 URL 都不起作用,无论是账单、偏好设置、活动还是其他任何页面。我是不是做错了什么?我应该使用什么呢?(请注意,这仅在 if 语句中不工作。在其他情况下,使用 /my 一直都能正常工作。)
<script type="text/discourse-plugin" version="0.8">
api.registerConnectorClass("above-user-profile", "back-button", {
setupComponent(args, component) {
api.onPageChange((url) => {
if (url === "/my/billing/subscriptions" ){
document.querySelector("html").classList.add("custom-homepage");
component.set("displayCustomHomepage", true);
} else {
document.querySelector("html").classList.remove("custom-homepage");
component.set("displayCustomHomepage", false);
}
});
}
});
</script>
<script type="text/x-handlebars" data-template-name="/connectors/above-user-profile/back-button">
{{#if displayCustomHomepage}}
<a href="https://mathbymiles.com/my/preferences" class="btn btn-default">
<span class="d-button-label">
返回设置!
</span>
</a>
{{/if}}
</script>