1.        用Sencha Cmd生成应用程序模版

sencha -sdk /path/to/ExtSDK generate app -classic TutorialApp./TutorialApp

2.        创建Login View组件

在./TutorialApp的“app/view/”目录下,有缺省的main目录,这个目录包括了文件Main.jsMainController.js,和 MainModel.js。

在“app/view/”目录下创建一个目录“login”,在“login”目录下,新建两个文件
Login.js和LoginController.js。

3.        从“{appRoot}/app.js”中移除mainView。

4.        创建Login窗体。文件 “{appRoot}/app/view/login/Login.js” 的内容例如以下:

Ext.define('TutorialApp.view.login.Login',{

extend: 'Ext.window.Window',

xtype: 'login',

requires: [

'TutorialApp.view.login.LoginController',

'Ext.form.Panel'

],

controller: 'login',

bodyPadding: 10,

title: 'Login Window',

closable: false,

autoShow: true,

items: {

xtype: 'form',

reference: 'form',

items: [{

xtype: 'textfield',

name: 'username',

fieldLabel: 'Username',

allowBlank: false

}, {

xtype: 'textfield',

name: 'password',

inputType: 'password',

fieldLabel: 'Password',

allowBlank: false

}, {

xtype: 'displayfield',

hideEmptyLabel: false,

value: 'Enter any non-blank password'

}],

buttons: [{

text: 'Login',

formBind: true,

listeners: {

click: 'onLoginClick'

}

}]

}

});

5.        添加Login逻辑,“{appRoot}/app/view/login/LoginController.js ”文件的内容例如以下:

Ext.define('TutorialApp.view.login.LoginController',{

extend: 'Ext.app.ViewController',

alias: 'controller.login',

onLoginClick: function() {

// This would be the ideal location to verify the user's credentials via

// a server-side lookup. We'll just move forward for the sake of thisexample.

// Set the localStorage value to true

localStorage.setItem("TutorialLoggedIn", true);

// Remove Login Window

this.getView().destroy();

// Add the main view to the viewport

Ext.create({

xtype: 'app-main'

});

}

});

6.        在Application.js中添加Launch逻辑。Application.js文件例如以下:

Ext.define('TutorialApp.Application', {

extend: 'Ext.app.Application',

name: 'TutorialApp',

stores: [

// TODO: add global / shared stores here

],

views: [

'TutorialApp.view.login.Login',

'TutorialApp.view.main.Main'

],

launch: function () {

// It's important to note that this type of application could use

// any type of storage, i.e., Cookies,LocalStorage, etc.

var loggedIn;

// Check to see the current value of the localStorage key

loggedIn = localStorage.getItem("TutorialLoggedIn");

// This ternary operator determines the value of the TutorialLoggedInkey.

// If TutorialLoggedIn isn't true, we display the login window,

// otherwise, we display the main view

Ext.create({

xtype: loggedIn ? 'app-main' : 'login'

});

},

onAppUpdate: function () {

Ext.Msg.confirm('Application Update', 'This application has an update,reload?

',

function (choice) {

if (choice === 'yes') {

window.location.reload();

}

}

);

}

});

7.        添加Viewport Plugin和Logoutbutton,“ {appRoot}/app/view/main/Main.js”文件例如以下:

Ext.define('TutorialApp.view.main.Main', {

extend: 'Ext.tab.Panel',

xtype: 'app-main',

requires: [

'Ext.plugin.Viewport',

'Ext.window.MessageBox',

'TutorialApp.view.main.MainController',

'TutorialApp.view.main.MainModel',

'TutorialApp.view.main.List'

],

controller: 'main',

viewModel: 'main',

plugins: 'viewport',

ui: 'navigation',

tabBarHeaderPosition: 1,

titleRotation: 0,

tabRotation: 0,

header: {

layout: {

align: 'stretchmax'

},

title: {

bind: {

text: '{name}'

},

flex: 0

},

iconCls: 'fa-th-list',

items: [{

xtype: 'button',

text: 'Logout',

margin: '10 0',

handler: 'onClickButton'

}]

},

tabBar: {

flex: 1,

layout: {

align: 'stretch',

overflowHandler: 'none'

}

},

responsiveConfig: {

tall: {

headerPosition: 'top'

},

wide: {

headerPosition: 'left'

}

},

defaults: {

bodyPadding: 20,

tabConfig: {

plugins: 'responsive',

responsiveConfig: {

wide: {

iconAlign: 'left',

textAlign: 'left'

},

tall: {

iconAlign: 'top',

textAlign: 'center',

width: 120

}

}

}

},

items: [{

title: 'Home',

iconCls: 'fa-home',

// The following grid shares a store with the classic version's grid aswell!

items: [{

xtype: 'mainlist'

}]

}, {

title: 'Users',

iconCls: 'fa-user',

bind: {

html: '{loremIpsum}'

}

},{

title: 'Groups',

iconCls: 'fa-users',

bind: {

html: '{loremIpsum}'

}

}, {

title: 'Settings',

iconCls: 'fa-cog',

bind: {

html: '{loremIpsum}'

}

}]

});

8.        添加main逻辑。 “{appRoot}/app/view/main/MainController.js”文件例如以下:

Ext.define('TutorialApp.view.main.MainController',{

extend: 'Ext.app.ViewController',

alias: 'controller.main',

onItemSelected: function (sender, record) {

Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);

},

onConfirm: function (choice) {

if (choice === 'yes') {

//

}

},

onClickButton: function () {

// Remove the localStorage key/value

localStorage.removeItem('TutorialLoggedIn');

// Remove Main View

this.getView().destroy();

// Add the Login Window

Ext.create({

xtype: 'login'

});

}

});

EXT-JS 6演示样例程序-Login演示样例程序的更多相关文章

  1. 将Ext JS 6应用程序导入Web项目

    由于Ext JS 6包含了Sencha Touch,因而在应用程序结构有了些改变,Ext JS 5的方法已经不适用于新版本了.经过研究,发现6导入Web项目要比5简单. 下面来说说导入的过程. 使用S ...

  2. 【翻译】探究Ext JS 5和Sencha Touch的布局系统

    原文:Exploring the Layout System in Ext JS 5 and Sencha Touch 布局系统是Sencha框架中最强大和最有特色的一个部分. 布局要处理应用程序中每 ...

  3. 【翻译】Sencha Ext JS 5公布

    原文:Announcing Sencha Ext JS 5 简单介绍 我代表Sencha和整个Ext JS团队,非常自豪的宣布,在今天,Sencha Ext JS 5公布了.Ext JS 5已经迈出了 ...

  4. 【翻译】如何创建Ext JS暗黑主题之一

    原文:How to Create a Dark Ext JS Theme– Part 1 概述 我是不是都要演示我的Spotifinder Ext JS应用程序.它是一个很酷的应用程序,可连接到Las ...

  5. Ext JS 4 新特性2:配置项属性(config)之二

    Ext JS 4 新特征2:配置项属性config之二 ☞ Config(自动的setters和getters) Ext JS 4介绍了config声明方式,在Ext JS 中也有几个例子:在运行程序 ...

  6. 【翻译】了解Ext JS 5的小部件

    原文:Understanding Widgets in Ext JS 5 在Ext JS 5,引入了新的"widgetcolumn",支持在网格的单元格中放置组件.同时,还在Ext ...

  7. 【翻译】Sencha Ext JS 5发布

    原文:Announcing Sencha Ext JS 5 简介 我代表Sencha和整个Ext JS团队,很自豪的宣布,在今天,Sencha Ext JS 5发布了.Ext JS 5已经迈出了一大步 ...

  8. 【翻译】对于Ext JS 5,你准备好了吗?

    原文:Are You Ready for Ext JS 5? Ext JS 5:准备升级 对于Ext JS 5加入Sencha的大家庭,我们感到非常高兴!作为一个主要版本,在Ext JS 5引入了一堆 ...

  9. 【翻译】Ext JS 5的委托事件和手势

    原文:Delegated Events and Gestures in Ext JS 5 简介 Ext JS在5之前的版本,被设计为专用于传统鼠标输入的桌面设备使用.而从5开始,添加了对触屏输入的支持 ...

  10. 使用Ext JS,不要使用页面做组件重用,尽量不要做页面跳转

    今天,有人请教我处理办法,问题是: 一个Grid,选择某条记录后,单击编辑后,弹出编辑窗口(带编辑表单),编辑完成后单击保存按钮保存表单,并关闭窗口,刷新Grid. 这,本来是很简单的,但囿于开发人员 ...

随机推荐

  1. HDU 5301 Buildings 数学

    Buildings 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5301 Description Your current task is to m ...

  2. C# 基于正则表达式的字符串验证

    输入的字符串校验,是开发中经常遇到的问题,常用的办法是利用正则表达式进行判断.其特点是简洁有效. 1.正则表达基础知识 正则表达式的教程很多,这里两个基础教程: a.http://www.cnblog ...

  3. linux基础命令学习(四)用户与群组

    一.linux用户账号的管理 linux用户账号的管理主要包括用户添加.用户删除.用户修改. 添加用户账号就是在系统创建一个新账号,然后为新账号分为用户号.用户组.主目录和登录Shell等资源. 刚添 ...

  4. How to create functions that can accept variable number of parameters such as Format

    http://www.chami.com/tips/delphi/112696D.html Sometimes it's necessary to pass undefined number of [ ...

  5. NFC TI TRF7970A Breakout Board for BusPirate or other HW

    http://dangerousprototypes.com/forum/viewtopic.php?f=19&t=3187 Just a news about a new Hardware ...

  6. 【资料】wod地城掉落

    •林中强盗第三层樵夫的皮带子蓝色毡帽面包刀(必定掉) •前往米勒巴赫的旅程第一层木棒邪恶强盗披风邪恶强盗匕首第二层地精盾第三层一瓶啤酒(必定掉大啤酒杯(必定掉 •喧嚷的酒吧第一层指挥棒(传奇等级10旅 ...

  7. Appium+python自动化13-native和webview切换

    前言 现在大部分app都是混合式的native+webview,对应native上的元素通过uiautomatorviewer很容易定位到,webview上的元素就无法识别了. 一.识别webview ...

  8. 推荐两份学习 Kotlin 和机器学习的资料

    最近 Kotlin 和人工智能比较火,有不少同学留言问我怎么学习 Kotlin,怎么学习机器学习,今天就给大家推荐两份不错的学习资料. 1. Kotlin 学习资料其实,在我看来最好的学习资料就是 K ...

  9. PostgreSql 合并多行记录

    需求描述: A表有如下数据 id 1 2 3 4 B表有如下数据 id name 1 aaa 1 bbb 1 ccc 2 aa 2 bb 3 c A表和B表通过id关联,需要查询结果如下: id na ...

  10. 各浏览器CSS兼容问题

    CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并 整理了一下.对于web2.0的过度,请尽量用xhtml ...