import router from "./router";
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import 'element-ui/lib/theme-chalk/display.css';
import Viewer from 'v-viewer';
import {
  getToken, removeMenu,
  removeBtn, removeToken
} from '@/utils/auth'
import ElementUI from 'element-ui'
import 'viewerjs/dist/viewer.css'

import "element-ui/lib/theme-chalk/display.css";
import "./styles/element-variables.scss";

import './styles/index.scss' // global css
import globalComponents from './components/globalComponents'
import App from './App'
import store from './store'
import base from './assets/utils/prototype/index'
// require('./mock')

import * as filters from './filters' // global filters

Array.prototype.remove = function (val) {
  var index = this.indexOf(val);
  if (index > -1) {
    this.splice(index, 1);
  }
};
// 兼容
if (typeof String.prototype.startsWith != "function") {
  String.prototype.startsWith = function (prefix) {
    return this.slice(0, prefix.length) === prefix;
  };
}

Vue.use(globalComponents)
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
Vue.use(base)
import PuzzleVerification from 'vue-puzzle-verification'
Vue.use(PuzzleVerification)


// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false
Vue.use(ElementUI)
window.vm = new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");


if (getToken() === null || getToken() === undefined || getToken() === '') {
  removeMenu()
  removeBtn()
  removeToken()
  router.replace({ name: 'login' });
}
