import config from './base/libs/config';
import eventBus from './base/libs/eventBus';
import router from './base/libs/router';
import timer from './base/libs/timer';
import memory from './base/libs/memory';
import util from './base/libs/util';
import wxApi from './base/libs/wxApi';
import eventLock from './base/libs/eventDelayLock';
import AgentPage from './base/constructor/agentPage';
import controller from './base/libs/global';
import request from './base/libs/request';

const appInit = () => {
    Object.defineProperties(global, {
        'config': {
            value: config,
            writable: false,
            configurable: false
        },
        'Page': {
            value: AgentPage,
            writable: false,
            configurable: false
        },
        'request': {
            value: request,
            writable: false,
            configurable: false
        },
        'func': {
            value: controller,
            writable: false,
            configurable: false
        },
        'router': {
            value: router,
            writable: false,
            configurable: false
        },
        'memory': {
            value: memory,
            writable: false,
            configurable: false
        },
        'eventBus': {
            value: eventBus,
            writable: false,
            configurable: false
        },
        'wx': {
            value: wxApi,
            writable: false,
            configurable: false
        },
        'ROUTER_TYPE': {
            value: {
                //默认的路由方式，保存当前页面
                CLOSE_NONE: 1,
                //关闭当前页面，并跳转
                CLOSE_CURRENT: 2,
                //关闭所有页面，并跳转
                CLOSE_ALL: 3,
                //回退至某个页面
                BACK: 4,
                //tab切换
                SWITCH_TAB: 5,
            },
            writable: false,
            configurable: false
        },
        'tools': {
            value: {
                util,
                eventLock,
                timer,
                memory
            },
            writable: false,
            configurable: false
        }
    });
}
appInit();

App({
    onLaunch: function () {
        
    },
    globalData: {}
})