Newer
Older
baseResourceFront / src / main.js
StephanieGitHub on 5 Mar 2021 2 KB first commit
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import '../theme/index.css' // 引入自定义主题
import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// echart
// import echarts from 'echarts'
// Vue.prototype.$echarts = echarts

// 将自动注册所有组件为全局组件
// import dataV from '@jiaminghi/data-view'
// Vue.use(dataV)

// 加载leaflet的css
import 'leaflet/dist/leaflet.css'
import 'leaflet-draw/dist/leaflet.draw.css'

/**
 * This project originally used easy-mock to simulate data,
 * but its official service is very unstable,
 * and you can build your own service if you need it.
 * So here I use Mock.js for local emulation,
 * it will intercept your request, so you won't see the request in the network.
 * If you remove `../mock` it will automatically request easy-mock data.
 */
// import './../mock' // simulation data
// require('./../mock')
// 兼容IE11
import 'babel-polyfill'

// 引入animate.css库,此处关闭eslint校验
// eslint-disable-next-line
import animate from 'animate.css'

import { hasPermission } from './utils/permission'

Vue.prototype.hasPerm = hasPermission
// 引入Element-ui
Vue.use(ElementUI, { locale })

// 引入全局标题
// import { getProject } from '@/utils/baseConfig'
// document.title = getProject().title

// 引入v-charts
// import VCharts from 'v-charts'
// Vue.use(VCharts)

// 先加载配置文件后,new Vue
/* eslint-disable no-new */
import axios from 'axios'
import service from '@/utils/request'
axios.get('./static/project.config.json').then((result) => {
  console.log('get config')
  Vue.prototype.baseConfig = result.data
  document.title = result.data.title // 首先设置网页的title
  service.defaults.baseURL = result.data.baseUrl // 设置默认请求网址
  new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
  })
}).catch((error) => {
  console.log('get baseConfig error...' + error)
})