如何在Application.js文件中推迟加载商店?
问题是我需要首先进行身份验证才能在使用其他代理加载存储之前获取我的cookie,否则我会收到一堆401错误。
从Application.js中删除所需的商店不起作用(应用程序无法加载)。因此,我需要找到一种方法来推迟加载所需的商店,直到我成功验证后。
我的登录子系统基于:sample login for ExtJS 如果身份验证成功,则会加载我的主视图(即,根据Application.js中的相关部分写入本地存储)
我的Application.js看起来像:
Ext.Loader.setConfig({
enabled: true,
paths: {
'Ext.ux.exporter': 'exporter',
'Overrides': 'overrides'
}
});
Ext.define('cardioCatalogQT.Application', {
extend: 'Ext.app.Application',
name: 'cardioCatalogQT',
requires: [
'Ext.app.*',
'cardioCatalogQT.config.Config',
'Ext.ux.exporter.Exporter',
'Ext.state.CookieProvider',
'Ext.window.MessageBox',
'Ext.tip.QuickTipManager',
'Ext.form.Panel',
'Ext.ux.form.MultiSelect',
'Ext.ux.form.ItemSelector',
'cardioCatalogQT.*',
'Ext.overrides.selection.CheckboxModel',
'Ext.overrides.view.MultiSelectorSearch'
],
stores: [
'Attributes',
'BasicVitals',
'Diagnoses',
'Labs',
'Procedures',
'Payload',
'Queries',
'Results',
'TestResults',
'Races',
'Ethnicities'
],
init: function() {
},
views: [
'cardioCatalogQT.view.login.Login',
'cardioCatalogQT.view.main.Main'
],
launch: function () {
Ext.Loader.setConfig({enabled: true});
// Static parameters
cardioCatalogQT.config = {
protocol: 'http://',
host: 'localhost',
apiGetQ: '/queryview/api/test',
apiWriteQ: '/queryview/api/create',
apiReadQ: '/remote_query_get',
remove: 'none'
};
// 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("CCLoggedIn");
// This ternary operator determines the value of the TutorialLoggedIn key.
// If TutorialLoggedIn isn't true, we display the login window,
// otherwise, we display the main view
Ext.widget(loggedIn ? 'main-view' : 'login');
// TODO - Launch the application
Ext.onReady(function () {
});
}
});