mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
@ -6,6 +6,7 @@ export interface IonicConfig {
|
||||
* Possible values are: `"ios"` or `"md"`.
|
||||
*/
|
||||
mode?: Mode;
|
||||
_persist?: boolean;
|
||||
|
||||
isDevice?: boolean;
|
||||
statusbarPadding?: boolean;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'ionicons';
|
||||
|
||||
import { configFromURL } from '../utils/config';
|
||||
import { configFromSession, configFromURL, saveConfig } from '../utils/config';
|
||||
import { isIOS } from '../utils/platform';
|
||||
|
||||
import { Config } from './config';
|
||||
@ -16,10 +16,15 @@ Object.defineProperty(Ionic, 'queue', {
|
||||
|
||||
// create the Ionic.config from raw config object (if it exists)
|
||||
// and convert Ionic.config into a ConfigApi that has a get() fn
|
||||
const config = Ionic['config'] = Context['config'] = new Config({
|
||||
const configObj = {
|
||||
...Ionic['config'],
|
||||
...configFromSession(),
|
||||
...configFromURL()
|
||||
});
|
||||
};
|
||||
const config = Ionic['config'] = Context['config'] = new Config(configObj);
|
||||
if (config.getBoolean('_persist', false)) {
|
||||
saveConfig(configObj);
|
||||
}
|
||||
|
||||
// first see if the mode was set as an attribute on <html>
|
||||
// which could have been set by the user, or by prerendering
|
||||
|
@ -16,6 +16,16 @@ export function setupConfig(config: IonicConfig) {
|
||||
}
|
||||
|
||||
const IONIC_PREFIX = 'ionic:';
|
||||
const IONIC_SESSION_KEY = 'ionic-persist-config';
|
||||
|
||||
export function configFromSession(): any {
|
||||
const configStr = window.sessionStorage.getItem(IONIC_SESSION_KEY);
|
||||
return configStr ? JSON.parse(configStr) : {};
|
||||
}
|
||||
|
||||
export function saveConfig(config: any) {
|
||||
window.sessionStorage.setItem(IONIC_SESSION_KEY, JSON.stringify(config));
|
||||
}
|
||||
|
||||
export function configFromURL() {
|
||||
const config: any = {};
|
||||
|
Reference in New Issue
Block a user