import App from "./App.vue";
import Components from "./components/reports";
import * as filters from './filters' // global filters
import router from "./router"

// import VConsole from "vconsole";

import {
  Table,
  Select,
  Option,
  DatePicker
} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';


const ua = window.navigator.userAgent.toLowerCase();

import { getParameterByName } from "@/utils/auth"
const code = getParameterByName("code");
const back = getParameterByName("back");


// 是否为微信环境
const isWechat = ua.match(/micromessenger/i) == 'micromessenger'
if (isWechat && !code) {
  router.push("/" + "?back=" + back)
}

if (!isWechat) {
  router.push("/wechat" + "?back=" + back)
}

// new VConsole();

Vue.component(Table.name, Table);
Vue.component(Select.name, Select);
Vue.component(Option.name, Option);
Vue.component(DatePicker.name, DatePicker);

// Vue.config.ignoreElements = ['wx-open-subscribe']

Vue.use(router)
Vue.use(Components);

Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))
Vue.config.productionTip = false;

window.vm = new Vue({
  router,
  render: h => h(App)
}).$mount("#app");
