main.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // 成功/错误提示
  31. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  32. Vue.prototype.$successMsg = successMsg
  33. Vue.prototype.$errorMsg = errorMsg
  34. Vue.prototype.$warningNotify = warningNotify
  35. Vue.prototype.$checkBtnRole = checkBtnRole
  36. Vue.prototype.$getSummaries = getSummaries
  37. Vue.prototype.$numToFixed = numToFixed
  38. Vue.prototype.$startLoading = startLoading
  39. Vue.prototype.$endLoading = endLoading
  40. // 自定义组件
  41. import ExportButton from '@/components/Common/export-button.vue'
  42. Vue.component('ExportButton', ExportButton)
  43. import ImportButton from '@/components/Common/import-button.vue'
  44. Vue.component('ImportButton', ImportButton)
  45. import CopyButton from '@/components/Common/copy-button.vue'
  46. Vue.component('CopyButton', CopyButton)
  47. import Collapse from '@/components/Common/collapse'
  48. Vue.component('Collapse', Collapse)
  49. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_API + 'img/get?key='
  50. /**
  51. * If you don't want to use mock-server
  52. * you want to use MockJs for mock api
  53. * you can execute: mockXHR()
  54. *
  55. * Currently MockJs will be used in the production environment,
  56. * please remove it before going online ! ! !
  57. */
  58. if (process.env.NODE_ENV === 'production') {
  59. const { mockXHR } = require('../mock')
  60. mockXHR()
  61. }
  62. // set ElementUI lang to EN
  63. // Vue.use(ElementUI, { locale })
  64. // 如果想要中文版 element-ui,按如下方式声明
  65. Vue.use(ElementUI)
  66. // register global utility filters
  67. Object.keys(filters).forEach(key => {
  68. Vue.filter(key, filters[key])
  69. })
  70. Object.keys(directives).forEach(key => {
  71. Vue.directive(key, directives[key])
  72. })
  73. Vue.config.productionTip = false
  74. new Vue({
  75. el: '#app',
  76. router,
  77. store,
  78. render: h => h(App)
  79. })