由于最近我关注移动开发没有以前多了,所以可能有些描述不准确,望指正,也希望给有些朋友带来一些帮助。

Alloy是一个Appcelerator公司的新的Titanium框架,它采用MVC结构,可以帮助开发者更快更有质量的创造Titanium应用。

下载地址和更多的介绍都在:https://github.com/appcelerator/alloy
Alloy 可以通过 Node.JS NPM模块安装(前提是需要安装好nodejs和npm的环境) ,然后使用下面的命令:

[sudo] npm install -g alloy

本地安装:

先克隆到本地
git clone https://github.com/appcelerator/alloy.git

然后安装
[sudo] npm install -g .

创建一个App

首先通过Titanium Studio或者是Titanium的CLI创建一个项目。然后在控制台,进入项目的根目录输入如下命令:

alloy new .

 

你的Alloy项目会有一个新的叫做app的目录,这个目录会包含alloy app的骨架。

目录结构如下
——————–

Alloy has directories that should be familiar if you’ve used any of the popular web MVC frameworks like Ruby on Rails.

Alloy prefers to use convention over configuration for simplicity.

– *views* – this is where your views should go in the format _*view*.xml_
– *controllers* – this is where your controllers should go in the format _*view*.js_.
– *styles* – this is where your view styling logic should go in the format _*view*.json_.
– *models* – this is where your model files will go.
– *assets* – this is where you should put your image assets and other misc. files that you want copied into the _Resources_ directory.
– *migrations* – this is where your database migration files will be stored.
– *lib* – this is where you should put application specific files, typically in the CommonJS format.
– *vendor* – this is where you should put any vendor specific modules, typically in the CommonJS format. Do not place native modules in this folder.
– *config* – Contains application specific config.

编译应用

—————-

你可以运行alloy 就像运行一个正常的项目,但是你也可以使用下面的命令

alloy compile

如果你运行了这个命令,他们自动编译文件到Resources目录

创建views

alloy generate view <name>

创建Controllers

alloy generate controller <name>

创建Models

alloy generate model <name> [column_name:type, …]

例如:

alloy generate model todo name:string active:boolean