main.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 '@zjlib/element-ui2'
  5. import '@zjlib/element-ui2/lib/theme-chalk/index.css'
  6. // import locale from '@zjlib/element-ui2/lib/locale/lang/en' // lang i18n
  7. import { Loading } from '@zjlib/element-ui2'
  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. window._AMapSecurityConfig = {
  31. serviceHost: 'https://jiasm.zfire.top/' + '_AMapService'
  32. }
  33. import '@zjlib/element-plugins/dest/element-plugins.css'
  34. import ElementPlugins, { AMap } from '@zjlib/element-plugins'
  35. Vue.use(ElementPlugins)
  36. Vue.use(AMap)
  37. AMap.initAMapApiLoader({
  38. // 高德的key
  39. key: '5894bf90997454b0df3c3d60cab12f64',
  40. version: '2.0',
  41. plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
  42. })
  43. import { getIPAdd } from '@/utils/lbs.js'
  44. getIPAdd()
  45. .then(res => {
  46. Vue.prototype.$IpAdd = res.data
  47. })
  48. .catch(() => {})
  49. // // 本地引用;
  50. // import ElementPlugins from '@packages'
  51. // Vue.use(ElementPlugins)
  52. // 成功/错误提示
  53. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  54. Vue.prototype.$successMsg = successMsg
  55. Vue.prototype.$errorMsg = errorMsg
  56. Vue.prototype.$warningNotify = warningNotify
  57. Vue.prototype.$checkBtnRole = checkBtnRole
  58. Vue.prototype.$getSummaries = getSummaries
  59. Vue.prototype.$numToFixed = numToFixed
  60. Vue.prototype.$startLoading = startLoading
  61. Vue.prototype.$endLoading = endLoading
  62. // 自定义组件
  63. import ExportButton from '@/components/Common/export-button.vue'
  64. Vue.component('ExportButton', ExportButton)
  65. import ImportButton from '@/components/Common/import-button.vue'
  66. Vue.component('ImportButton', ImportButton)
  67. import CopyButton from '@/components/Common/copy-button.vue'
  68. Vue.component('CopyButton', CopyButton)
  69. import Collapse from '@/components/Common/collapse'
  70. Vue.component('Collapse', Collapse)
  71. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_API + 'img/get?key='
  72. /**
  73. * If you don't want to use mock-server
  74. * you want to use MockJs for mock api
  75. * you can execute: mockXHR()
  76. *
  77. * Currently MockJs will be used in the production environment,
  78. * please remove it before going online ! ! !
  79. */
  80. if (process.env.NODE_ENV === 'production') {
  81. const { mockXHR } = require('../mock')
  82. mockXHR()
  83. }
  84. // set ElementUI lang to EN
  85. // Vue.use(ElementUI, { locale })
  86. // 如果想要中文版 element-ui,按如下方式声明
  87. Vue.use(ElementUI)
  88. // register global utility filters
  89. Object.keys(filters).forEach(key => {
  90. Vue.filter(key, filters[key])
  91. })
  92. Object.keys(directives).forEach(key => {
  93. Vue.directive(key, directives[key])
  94. })
  95. Vue.config.productionTip = false
  96. new Vue({
  97. el: '#app',
  98. router,
  99. store,
  100. render: h => h(App)
  101. })