main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import Vue from 'vue'
  2. import 'normalize.css/normalize.css' // A modern alternative to CSS resets
  3. // import './plugins/jquery.hiwprint.js'
  4. import ElementUI from 'element-ui'
  5. import 'element-ui/lib/theme-chalk/index.css'
  6. // import locale from 'element-ui/lib/locale/lang/en' // lang i18n
  7. import { Loading } from 'element-ui'
  8. let loading
  9. function startLoading() {
  10. loading = Loading.service({
  11. lock: true,
  12. text: '拼命加载中...',
  13. spinner: 'el-icon-loading',
  14. customClass: '.app-container'
  15. })
  16. }
  17. function endLoading() {
  18. loading.close()
  19. }
  20. import * as echarts from 'echarts'
  21. Vue.prototype.$echarts = echarts
  22. import '@/styles/index.scss' // global css
  23. import App from './App'
  24. import store from './store'
  25. import router from './router'
  26. import '@/icons' // icon
  27. import '@/permission' // permission control
  28. import * as filters from './filters' // global filters
  29. import directives from './directives'
  30. import '@zjlib/element-plugins/dest/element-plugins.css'
  31. import ElementPlugins, { AMap } from '@zjlib/element-plugins'
  32. Vue.use(ElementPlugins)
  33. Vue.use(AMap)
  34. AMap.initAMapApiLoader({
  35. // 高德的key
  36. key: '5894bf90997454b0df3c3d60cab12f64',
  37. version: '2.0',
  38. plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
  39. })
  40. // // 本地引用;
  41. // import ElementPlugins from '@packages'
  42. // Vue.use(ElementPlugins)
  43. // 成功/错误提示
  44. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  45. Vue.prototype.$successMsg = successMsg
  46. Vue.prototype.$errorMsg = errorMsg
  47. Vue.prototype.$warningNotify = warningNotify
  48. Vue.prototype.$checkBtnRole = checkBtnRole
  49. Vue.prototype.$getSummaries = getSummaries
  50. Vue.prototype.$numToFixed = numToFixed
  51. Vue.prototype.$startLoading = startLoading
  52. Vue.prototype.$endLoading = endLoading
  53. // 自定义组件
  54. import ExportButton from '@/components/Common/export-button.vue'
  55. Vue.component('ExportButton', ExportButton)
  56. import ImportButton from '@/components/Common/import-button.vue'
  57. Vue.component('ImportButton', ImportButton)
  58. import CopyButton from '@/components/Common/copy-button.vue'
  59. Vue.component('CopyButton', CopyButton)
  60. import Collapse from '@/components/Common/collapse'
  61. Vue.component('Collapse', Collapse)
  62. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_API + 'img/get?key='
  63. /**
  64. * If you don't want to use mock-server
  65. * you want to use MockJs for mock api
  66. * you can execute: mockXHR()
  67. *
  68. * Currently MockJs will be used in the production environment,
  69. * please remove it before going online ! ! !
  70. */
  71. if (process.env.NODE_ENV === 'production') {
  72. const { mockXHR } = require('../mock')
  73. mockXHR()
  74. }
  75. // set ElementUI lang to EN
  76. // Vue.use(ElementUI, { locale })
  77. // 如果想要中文版 element-ui,按如下方式声明
  78. Vue.use(ElementUI)
  79. // register global utility filters
  80. Object.keys(filters).forEach(key => {
  81. Vue.filter(key, filters[key])
  82. })
  83. Object.keys(directives).forEach(key => {
  84. Vue.directive(key, directives[key])
  85. })
  86. Vue.config.productionTip = false
  87. new Vue({
  88. el: '#app',
  89. router,
  90. store,
  91. render: h => h(App)
  92. })