import Vue from 'vue'
import App from './App'

import VueRouter from 'vue-router'

import './assets/js/rem.js'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import Mint from 'mint-ui';
import 'mint-ui/lib/style.css';

import store from './vuex/store'
import Vuex from 'vuex'
import routes from './routes'

import http from './http'
Vue.prototype.http = http

import port from './port'
Vue.prototype.port = port

import echarts from 'echarts'
Vue.prototype.echarts = echarts

import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

import 'font-awesome/css/font-awesome.min.css'
import './assets/iconfont/iconfont.css'

import picker from "./assets/js/custom-picker.js"
import "./assets/css/custom-picker.css"
Vue.use(picker)

Vue.use(ElementUI)
Vue.use(Mint);
Vue.use(VueRouter)
Vue.use(Vuex)

const router = new VueRouter({
    routes
})


router.beforeEach((to, from, next) => {
    if (to.path == '/login') {
        sessionStorage.clear();
    }

    let user = JSON.parse(sessionStorage.getItem('user'));
    if (!user && to.path != '/login') {
        next({ path: '/login' })
    } else {
        if(to.path == '/assets' || to.path == '/task' || to.path == '/my') {
            $(".tabber").show();
        } else {
            $(".tabber").hide();
        }
        next()
    }
})

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

