如何在流星中有条件地将模板和javascript文件发送到客户端? [英] How can I conditionally send templates and javascript files to the client in meteor?

查看:62
本文介绍了如何在流星中有条件地将模板和javascript文件发送到客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与之前提出的关于通过 meteor 有条件地向客户发送文档数据。

This is related to a previous question I asked about conditionally sending document data to the client in meteor.

假设我有类似于解析的数据编辑器/浏览器可用于标记为系统管理员的用户帐户,以及一些显示有关应用程序的日志记录信息的页面。我正在使用 meteor-router 和过滤器来完成此任务。

Lets say I have a parse-like data editor/browser available for user accounts marked as system admin, as well as some pages that show logging information about the app. I'm using meteor-router and a filter to accomplish this.

99%的用户不需要查看这些界面,但是他们的(大量)javascript仍然会被发送到客户端。管理员特定的javascript和模板被分成他们自己的文件,如何确保他们不会被不必要地发送到客户端(当登录用户不是管理员时)?

99% of users won't need to to see those interfaces, but the (massive amounts of) javascript for them is still sent to the client. The admin specific javascript and templates are separated into their own files, how can I make sure they are not sent to the client unnecessarily (when the logged in user is not an admin)?

最好选择将管理界面拆分为单独的应用并将其指向原始的mongo

推荐答案

如果您不希望Meteor自动加载客户端脚本,可以将它们放在/ public目录中并在需要时自行加载它们。

If you don't want Meteor to load your client-side scripts automatically, you could place them in the /public directory and load them yourself when you need them.

然而,在管理环境的情况下,从软件开发的角度来看,实际上可能更好地将所有这些分成自己的应用程序,指向与您相同的数据库说。

However, in the case of an admin environment, it may actually be better from a software development perspective to separate all of that into its own app, pointing to the same database like you said.

这篇关于如何在流星中有条件地将模板和javascript文件发送到客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆