import { createApp } from 'vue/dist/vue.esm-bundler.js'; import Antd from 'ant-design-vue'; import App from './App.vue'; import 'ant-design-vue/dist/antd.css'; import UCore from './utils/UCore.js'; import './assets/css/index.css'; import router from './router'; import Vuex from 'vuex' import store from './store/index.js'; import axios from 'axios'; import ElementPlus from 'element-plus'; import 'element-plus/lib/theme-chalk/index.css'; import 'dayjs/locale/zh-cn'; import locale from 'element-plus/lib/locale/lang/zh-cn'; //引入rem字体配置 import '@/assets/js/flexible.js'; // 引入字体样式 import '@/assets/fonts/font.css'; import * as echarts from 'echarts' import 'echarts/lib/component/tooltip'; import 'echarts/lib/component/title'; import 'echarts/lib/component/legend'; // import { ElMessage } from "element-plus"; import { removeToken } from './utils/auth'; const app = createApp(App); import Interface from "../public/InterfaceReturn.json" app.config.globalProperties.$Interface = Interface app.config.globalProperties.$UCore = UCore; app.config.globalProperties.$axios = axios; app.use(router).use(store).use(ElementPlus, { locale }).use(Vuex).use(echarts).use(Antd).mount('#app'); store.commit("getTimeAll"); /*路由守卫*/ router.beforeEach((to, from, next) => { /* 路由发生变化修改页面title */ if (to.meta.title) { document.title = to.meta.title } if (to.path !== '/') { if (localStorage.getItem('accessToken') === null) { removeToken()//不用管 // if (localStorage.getItem('userInfo') === null) { // 本地存储的accessToken不存在时,跳转至后台登录页 // alert('本地存储的accessToken不存在') // console.log(window.location.host.indexOf("localhost") != -1) if (window.location.host.indexOf("localhost") != -1) { next({ path: '/' }) } else if (window.location.host.indexOf("pcdev.ewoogi.com") != -1) { window.location.href = 'https://pcdev.ewoogi.com/adminfiv/#/login' } else { window.location.href = 'https://wx.ewoogi.com/manage/#/login' } document.getElementById('routers').style.display = "none" // setTimeout(() => { // ElMessage.warning({ // message: '请登录后重试!', // type: 'warning' // }) // }, 100); } else { // alert('本地存储的accessToken存在') next(); } } else { document.getElementById('routers').style.display = "block" //路由的next必须存在,否则无法进入下一页 if (localStorage.getItem('accessToken') != null) { next({ path: '/home' }) } else { next() } } })