let _app
let _num
let deferred = KanKan.Deferred()

export function createApp(opitons = {}) {
    if (_app) {
        return
    }
    // opitons.region = process.env.VUE_APP_REGION_URL
    opitons.resource = process.env.VUE_APP_RESOURCE_URL
    _num = opitons.num
    _app = new KanKan(opitons)
    deferred.resolve(_app)
    window.__sdk = _app
    document.body.setAttribute('is-mobile', true)
    return _app
}

export function useApp() {
    if (_app) {
        return Promise.resolve(_app)
    }
    return deferred
}

export function getApp() {
    return _app
}

export function getNum() {
    return _num
}
