// 类库相关
import Vue from 'vue'
import Vant from 'vant'
import Store from 'store'
import 'vant/lib/index.css'
import '@/styles/index.scss'

import App from './App.vue'

// 项目自定义
import axios from '@/https/request'
import API from '@/https/api'
import keys from '../../config/keys'
import utils from '../../utils'
import constants from '../../config/constant'

/* eslint-disable */
// ##兼容: IE 9 requestAnimationFrame
(function() {
  var lastTime = 0;
  var vendors = ['ms', 'moz', 'webkit', 'o'];
  for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
    window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
    window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
      || window[vendors[x]+'CancelRequestAnimationFrame'];
  }

  if (!window.requestAnimationFrame)
    window.requestAnimationFrame = function(callback, element) {
      var currTime = new Date().getTime();
      var timeToCall = Math.max(0, 16 - (currTime - lastTime));
      var id = window.setTimeout(function() { callback(currTime + timeToCall); },
        timeToCall);
      lastTime = currTime + timeToCall;
      return id;
    };

  if (!window.cancelAnimationFrame)
    window.cancelAnimationFrame = function(id) {
      clearTimeout(id);
    };
}());

Vue.use(Vant);
Vue.config.performance = true
Vue.config.productionTip = false

Vue.prototype.$https = axios
Vue.prototype.$API = API
Vue.prototype.$utils = utils
Vue.prototype.$keys = keys
Vue.prototype.$Store = Store
Vue.prototype.$consts = constants

new Vue({
  render: h => h(App)
}).$mount('#app')
