mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
docs(config): update demo for config, add more logs for app-scripts
closes #9413
This commit is contained in:
@ -3,21 +3,21 @@ import { Config, IonicApp, IonicModule, Platform, NavController } from '../../io
|
||||
|
||||
if (!window.localStorage) {
|
||||
Object.defineProperty(window, 'localStorage', new (function () {
|
||||
var aKeys = [], oStorage = {};
|
||||
var aKeys: any[] = [], oStorage = {};
|
||||
Object.defineProperty(oStorage, 'getItem', {
|
||||
value: function (sKey) { return sKey ? this[sKey] : null; },
|
||||
value: function (sKey: number) { return sKey ? this[sKey] : null; },
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(oStorage, 'key', {
|
||||
value: function (nKeyId) { return aKeys[nKeyId]; },
|
||||
value: function (nKeyId: number) { return aKeys[nKeyId]; },
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(oStorage, 'setItem', {
|
||||
value: function (sKey, sValue) {
|
||||
value: function (sKey: string, sValue: string) {
|
||||
if (!sKey) { return; }
|
||||
document.cookie = encodeURI(sKey) + '=' + encodeURI(sValue) + '; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/';
|
||||
},
|
||||
@ -31,7 +31,7 @@ if (!window.localStorage) {
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(oStorage, 'removeItem', {
|
||||
value: function (sKey) {
|
||||
value: function (sKey: string) {
|
||||
if (!sKey) { return; }
|
||||
document.cookie = encodeURI(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
},
|
||||
@ -40,21 +40,21 @@ if (!window.localStorage) {
|
||||
enumerable: false
|
||||
});
|
||||
this.get = function () {
|
||||
var iThisIndx;
|
||||
var iThisIndx: number;
|
||||
for (var sKey in oStorage) {
|
||||
iThisIndx = aKeys.indexOf(sKey);
|
||||
if (iThisIndx === -1) {
|
||||
(oStorage as any).setItem(sKey, oStorage[sKey]);
|
||||
(oStorage as any).setItem(sKey, (oStorage as any)[sKey]);
|
||||
} else {
|
||||
aKeys.splice(iThisIndx, 1);
|
||||
}
|
||||
delete oStorage[sKey];
|
||||
delete (oStorage as any)[sKey];
|
||||
}
|
||||
for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { (oStorage as any).removeItem(aKeys[0]); }
|
||||
for (var aCouple, iKey, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) {
|
||||
for (var aCouple: any, iKey: any, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) {
|
||||
aCouple = aCouples[nIdx].split(/\s*=\s*/);
|
||||
if (aCouple.length > 1) {
|
||||
oStorage[iKey = decodeURI(aCouple[0])] = decodeURI(aCouple[1]);
|
||||
(oStorage as any)[iKey = decodeURI(aCouple[0])] = decodeURI(aCouple[1]);
|
||||
aKeys.push(iKey);
|
||||
}
|
||||
}
|
||||
@ -62,10 +62,10 @@ if (!window.localStorage) {
|
||||
};
|
||||
this.configurable = false;
|
||||
this.enumerable = true;
|
||||
})());
|
||||
} as any)());
|
||||
}
|
||||
|
||||
var CONFIG_DEMO = null;
|
||||
var CONFIG_DEMO: any = null;
|
||||
|
||||
if (window.localStorage.getItem('configDemo')) {
|
||||
CONFIG_DEMO = JSON.parse(window.localStorage.getItem('configDemo'));
|
||||
@ -88,6 +88,7 @@ export class ApiDemoPage {
|
||||
initialConfig: any;
|
||||
constructor(_config: Config, public navCtrl: NavController) {
|
||||
this.config = _config.settings();
|
||||
this.initialConfig = this.config;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,15 +46,20 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p class="note">Any config for your app should be passed as the third argument to ionicBootstrap.</p>
|
||||
<p class="note">Any config for your app should be passed as the second argument to <code>IonicModule.forRoot()</code>.</p>
|
||||
|
||||
<!-- this has to be formatted weird for pre -->
|
||||
<pre margin>
|
||||
<!--ionicBootstrap(MyApp, [], {
|
||||
backButtonIcon: "{{initialConfig.backButtonIcon}}"
|
||||
iconMode: "{{initialConfig.iconMode}}"
|
||||
tabsPlacement: "{{initialConfig.tabsPlacement}}"
|
||||
});--></pre>
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicModule.forRoot(MyApp, {
|
||||
backButtonIcon: "{{initialConfig?.backButtonIcon}}"
|
||||
iconMode: "{{initialConfig?.iconMode}}"
|
||||
tabsPlacement: "{{initialConfig?.tabsPlacement}}"
|
||||
})
|
||||
]
|
||||
})
|
||||
</pre>
|
||||
|
||||
<div padding>
|
||||
<button ion-button block color="secondary" (click)="push()">
|
||||
|
@ -196,10 +196,13 @@ export function runAppScripts(folderInfo: any, sassConfigPath: string, appEntryP
|
||||
scriptArgs.push('--debug');
|
||||
}
|
||||
|
||||
console.log('$ ionic-app-scripts', scriptArgs.join(' '));
|
||||
|
||||
try {
|
||||
const scriptsCmd = spawnSync('ionic-app-scripts', scriptArgs);
|
||||
|
||||
if (scriptsCmd.status !== 0) {
|
||||
console.log(scriptsCmd.stderr.toString());
|
||||
return Promise.reject(scriptsCmd.stderr.toString());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user