import {
  showLoading,
  closeLoading
} from './utils/pop'

export function injectGlobalApi (Vue, store) {
  Vue.config.productionTip = false
  Vue.config.errorHandler = err => {
    closeLoading()
    throw err
  }

  Vue.prototype.__STAGING__ = __STAGING__
  Vue.prototype.__PLACEHOLDER__ = __PLACEHOLDER__

  Vue.prototype.roleSet = store.getters.roles
  Vue.prototype.accessSet = store.getters.accesses

  Vue.prototype.$showLoading = showLoading
  Vue.prototype.$closeLoading = closeLoading

  Vue.prototype.$designProgram = function (id) {
    window.open(this.$router.resolve({
      name: 'program',
      params: { id }
    }).href, '_blank')
  }
}
