2012-10-22 67 views
4

如何修改认证智能包?流星修改认证智能包

例如注册后的下拉框显示按钮更改密码并注销。我想添加一个编辑帐户按钮。怎么样?

谢谢。

回答

3

要添加编辑按钮,看看这里: https://github.com/meteor/meteor/tree/master/packages/accounts-ui-unstyled

具体来说,login_buttons.html文件。

更新:有在链接文件的上面有个字条:

NOTE: You shouldn't use these templates directly. Instead, use the global {{loginButtons}} template.

因此,你会发现在您的流星安装这些文件(我的是在C:\Program Files (x86)\Meteor\packages\accounts-ui\login_buttons.html)和编辑文件。

注意这将修改所有流星应用程序的帐户UI。如果您不希望更改影响其他流星应用程序,那么您可能必须“分叉”自己的accounts-ui软件包。

有关于使帐户用户界面更具可定制性的讨论(如可重写的模板),但目前版本的Meteor无法实现。我建议你向流星开发者描述你的用例。流星开发商openly welcome feedback

Feedback, please! Some specific areas that we're curious about:

  • What sort of customization do you want to do to the loginButtons template?

  • What sort of account restrictions are you likely to use? Everyone must have a username? Everyone must have an email?

+0

我只是将它复制到我的应用程序,然后将其替换? – Harry

+1

no go'未捕获错误:有多个名为'_loginButtons'的模板。每个模板需要一个唯一的名称。 @ – Harry

+0

@哈里:你应该找到并编辑现有的文件。我更新了我的答案。 – Leftium

0

您可以覆盖loginButtons,因为目前缺省的助手对象是公众出于某种原因:

Handlebars._default_helpers["loginButtons"] = function(options) { 
    return "hello this is test"; 
}; 

原始助手功能如下:

Handlebars.registerHelper(
    "loginButtons", 
    function (options) { 
    if (options.hash.align === "right") 
     return new Handlebars.SafeString(Template._loginButtons({align: "right"})); 
    else 
     return new Handlebars.SafeString(Template._loginButtons({align: "left"})); 
    }); 

在这里,您可以用您自己的模板替换默认的_loginButtons模板。

但是,这可能很容易与流星的未来版本打破,因为Handlebars._default_helpers并非真正用于这种方式。但至少你不必使用流星叉。

此外,您还必须确保在accounts-ui-unstyled之后添加助手。因此,如果您在另一个软件包中使用此技巧,请确保将accounts-ui-unstyled声明为依赖项。