import Vue from 'vue' import 'normalize.css/normalize.css' // A modern alternative to CSS resets import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' // import locale from 'element-ui/lib/locale/lang/en' // lang i18n import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n import '@/styles/index.scss' // global css import App from './App' import axios from 'axios' import store from './store' import router from './router' import Cookies from 'js-cookie' import Bus from '@/Bus' import '@/icons' // icon import '@/permission' // permission control // clipboard是一款实现复制文本到剪贴板功能的JS插件 import clipboard from 'clipboard' // 注册到vue原型上 Vue.prototype.$clipboard = clipboard // 高德地图 import AMap from 'vue-amap' Vue.use(AMap) AMap.initAMapApiLoader({ key: 'be57d4add7dc10fb7f7924763a2179ae', plugin: ['AMap.moveAnimation', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'AMap.DistrictSearch'], // 默认高德 sdk 版本为 1.4.4 v: '1.4.4' }) Vue.prototype.$AMap = AMap // crypto加密 import { Encrypt } from '@/utils/AES.js' import { getToken } from '@/utils/auth' import request from '@/utils/request' Vue.prototype.$request = request.service Vue.prototype.$axiosRequest = request.reqServe /** * If you don't want to use mock-server * you want to use MockJs for mock api * you can execute: mockXHR() * * Currently MockJs will be used in the production environment, * please remove it before going online! ! ! */ import { mockXHR } from '../mock' if (process.env.NODE_ENV === 'production') { mockXHR() } import echarts from 'echarts' Vue.prototype.$Cookies = Cookies Vue.prototype.$echarts = echarts Vue.prototype.$getToken = getToken Vue.prototype.$encrypt = Encrypt Vue.prototype.$axios = axios Vue.use(ElementUI, { locale }) Vue.config.productionTip = false Vue.prototype.$axios = axios Vue.prototype.$Bus = Bus function getServerConfig() { return new Promise((resolve, reject) => { axios.get('/serverConfig.json').then((result) => { // console.log(result) // 看打印出来的结果 const config = result.data for (const key in config) { Vue.prototype[key] = config[key] } // 验证是否已经把属性挂在了Vue上 // console.log(Vue.prototype.BASE_ADDR) resolve() }).catch((error) => { console.log(error) reject() }) }) } async function init() { await getServerConfig() axios.defaults.baseURL = Vue.prototype.BASE_API axios.defaults.headers['token'] = getToken() new Vue({ router, store, render: h => h(App) }).$mount('#app') } init()