在对望远镜源进行了一些挖掘之后,我得出了这个解决方案:
custom_view_menu.js
使用以下内容在您的自定义包中创建一个名为 ie 的文件:
getRoute = function (item) {
// if route is a Function return its result, else apply Router.path() to it
return typeof item.route == "function" ? item.route() : Router.path(item.route);
}
Template.menuItem.helpers({
itemClass: function () {
var itemClass = "";
var currentPath = Router.current().location.get().path;
if (this.adminOnly) {
itemClass += " item-admin";
}
if (getRoute(this) === currentPath || getRoute(this) === Meteor.absoluteUrl() + currentPath.substr(1)) {
// substr(1) is to avoid having two "/" in the URL
itemClass += " item-active";
}
if (this.label === Settings.get("defaultView") && currentPath === "/") {
itemClass += " item-active";
}
if (this.itemClass) {
itemClass += " "+this.itemClass;
}
return itemClass;
}
});
它是从原始来源( https://github.com/TelescopeJS/Telescope/blob/master/packages/telescope-core/lib/client/templates/menu/menu_component.js )复制的必需品,并添加了以下内容:
if (this.label === Settings.get("defaultView") && currentPath === "/") {
itemClass += " item-active";
}
我希望它会对某人有所帮助,而且我不是唯一一个尝试这样做的人:)