简体   繁体   English

如何实现Sencha Touch项目的文件夹结构?

[英]How to implement folder structure for Sencha Touch projects?

I am architecting a Sencha Touch project. 我正在设计一个Sencha Touch项目。 Sencha Touch command line lets you create controllers, views, models, stores but there is no standard way to architect the project. Sencha Touch命令行允许您创建控制器,视图,模型,存储,但是没有标准的方法来设计项目。 I want to place all my routes in one file , say app.routes.js. 我想将所有路线都放在一个文件中 ,例如app.routes.js。 Main controller to load views in one file , say mainController.js in which I want to write code to load different views. 主控制器将视图加载到一个文件中 ,例如mainController.js ,我想在其中编写代码以加载不同的视图。

Also I want to keep all templates in one file for ease of UI designers in one file, say app.templates.html so that I can append template file to document head on load and access different layouts and views using standard jQuery . 另外,我想将所有模板都保存在一个文件中 ,以便于UI设计人员将其放在一个文件中,例如app.templates.html,以便我可以在加载时将模板文件附加到文档的头上并使用标准jQuery访问不同的布局和视图 I went through different answers but didn't find any relevant answer. 我经历了不同的答案,但没有找到任何相关的答案。

Here's how am implementing routers- 这是实现路由器的方法-

Ext.Viewport.setActiveItem({xtype : 'main'});
    break;
    case '#_login':
        Ext.Viewport.setActiveItem({xtype : 'login'});
        break;
    case '#_terms':
        Ext.Viewport.setActiveItem({xtype : 'terms'});
        break;
    case '#_exams':
        Ext.Viewport.setActiveItem({xtype : 'exam'});
        break;
    case '#_enrollments':
        Ext.Viewport.setActiveItem({xtype : 'enroll'});
        break;
    case '#_examdetails':
        Ext.Viewport.setActiveItem({xtype : 'exammaterials'});
        break;
    case '#_enrollmentdetails':
        Ext.Viewport.setActiveItem({xtype : 'enroll'});
        break;
    case '#_mapdetails':
       Ext.Viewport.setActiveItem({xtype : 'mapview'});
        break;

If you use Sencha Cmd to create the project in the beginning you'll be setup with the folder structure you need. 如果您在一开始使用Sencha Cmd创建项目 ,则将使用所需的文件夹结构进行设置。

In the Terminal: 在终端中:

sencha -sdk /path/to/touch-xxx generate app MyApp /path/to/www/myapp

You will be setup with a directory structure like this... 您将使用这样的目录结构进行设置...

MyApp/
  |_ app/
  | |_ controller/
  | |_ model/
  | |_ store/
  | |_ view/
  |_ build/
  |_ packages/ ...
  |_ resources/ ...
  |_ touch/ ... <-- this folder is also generated for you.
  |_ app.js
  |_ app.json
  |_ bootstrap.js
  |_ bootstrap.json
  |_ build.xml
  |_ index.html
  |_ packager.json

I'm not sure about keeping the templates in one file but I've seen someone say they could keep their templates in the index.html file in script tags and reference it somehow. 我不确定要将模板保存在一个文件中,但是我看到有人说他们可以将模板保存在script标签中的index.html文件中,并以某种方式引用它。 Not sure about how that works. 不确定如何工作。

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

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