繁体   English   中英

如何在Meteor项目上组织文件夹和文件?

[英]How to organize folders and files on Meteor project?

创建项目时,我试图了解Meteor,到目前为止,我发现有些事情很难理解。

1-当他们说我可以创建serverclient文件夹时,我到底打算在哪里创建? .meteor兄弟姐妹? 启动应用程序时,一切都会在客户端或服务器的范围内吗?还是我需要做其他事情? 如果我在client文件夹中创建了一个foo.js和一个foo函数,是否可以在Meteor.isClient调用foo()且它可以正常工作?

2-我需要创建一个上传文件夹,以便人们可以上传他们的东西(图像)。 那我应该在哪里做呢? 另外,如何获得项目的绝对路径并在其中找到此upload文件夹?

在尝试过程中,我尝试了以下操作:

fs = Meteor.npmRequire('fs');
__ROOT_APP_PATH__ = fs.realpathSync('.');

但是__ROOT_APP_PATH__.meteor\\local\\build\\programs\\server 相当隐藏吧?

3-我看到有人直接在MongoDB上上传和保存文件。 这通常是关系数据库所不具备的。 我们将文件移动到CDN或我们自己的磁盘上的已知文件夹中,并保存该文件的哈希或名称,以便我们轻松找到它。 Meteor + MongoDB鼓励了吗? 为什么我将文件本身保存在Mongo上而不是将其移动到文件夹中?

没有任何特定的方法,但流星建议以这种方式进行http://docs.meteor.com/#/basic/filestructure

资料夹结构:

both/ (OR lib/)          -- common code for server and client
  |- collections/        -- declare collections (e.g Employer = new Meteor.Collection("employer");)
  |- router     /        -- router code(e.g Router.route(..))

client/                  -- client side code
  |- global/             -- all global variable for client
  |- helpers/            -- global helper for client (for all templates)
  |- plugins/            -- all the plugins code(if you use any)
  |- stylesheets/        -- css / less files
  |- templates/          -- all templates
        |- home.html     -- home template(html)
        |- home.js       -- home template(js)

public/                  -- images/icons/fonts (meteor looking at this file)

server/                  -- server code
  |- methods/            -- server methods/API (e.g Meteor.methods({...}))
  |- publish/            -- publish code from server

这是我遵循的流星项目的基本文件夹结构。 供进一步参考文档 如有任何问题,请随时在评论中提问。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM