main.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import { setToken } from '@/utils/auth'
  2. import { getUrlParam, findElem, deleteEmptyObj } from '@/utils/util'
  3. if (getUrlParam().token) {
  4. setToken(getUrlParam().token)
  5. }
  6. import Vue from 'vue'
  7. import 'normalize.css/normalize.css' // A modern alternative to CSS resets
  8. // import './plugins/jquery.hiwprint.js'
  9. import ElementUI from '@zjlib/element-ui2'
  10. import '@zjlib/element-ui2/lib/theme-chalk/index.css'
  11. import VueQuillEditor from 'vue-quill-editor'
  12. // require styles
  13. import 'quill/dist/quill.core.css'
  14. import 'quill/dist/quill.snow.css'
  15. import 'quill/dist/quill.bubble.css'
  16. Vue.use(VueQuillEditor /* { default global options } */)
  17. import VQuillEditor from '@/components/v-quill-editor'
  18. Vue.component('v-quill-editor', VQuillEditor)
  19. import { Loading } from '@zjlib/element-ui2'
  20. let loading
  21. function startLoading() {
  22. loading = Loading.service({
  23. lock: true,
  24. text: '拼命加载中...',
  25. spinner: 'el-icon-loading',
  26. customClass: '.app-container'
  27. })
  28. }
  29. function endLoading() {
  30. loading.close()
  31. }
  32. import * as echarts from 'echarts'
  33. Vue.prototype.$echarts = echarts
  34. import '@/styles/index.scss' // global css
  35. import App from './App'
  36. import store from './store'
  37. import router from './router'
  38. import '@/icons' // icon
  39. import '@/permission' // permission control
  40. import * as filters from './filters' // global filters
  41. import directives from './directives'
  42. window._AMapSecurityConfig = {
  43. serviceHost: 'https://jiasm.zfire.top/' + '_AMapService'
  44. }
  45. import '@zjlib/element-plugins/dest/element-plugins.css'
  46. import ElementPlugins, { AMap } from '@zjlib/element-plugins'
  47. Vue.use(ElementPlugins, {
  48. // 表单页面表单属性配置
  49. formAttributes: {
  50. 'label-position': 'right'
  51. }
  52. // // 操作记录配置
  53. // operationRecord: function (options) {
  54. // // console.log(options.meta.moduleId)
  55. // // return new Promise((r, j) => {
  56. // // r([[], []])
  57. // // })
  58. // }
  59. })
  60. Vue.use(AMap)
  61. AMap.initAMapApiLoader({
  62. // 高德的key
  63. key: '5894bf90997454b0df3c3d60cab12f64',
  64. version: '2.0',
  65. plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
  66. })
  67. // // 本地引用;
  68. // import ElementPlugins, { AMap } from '@packages'
  69. // Vue.use(ElementPlugins, {
  70. // formAttributes: {
  71. // 'label-position': 'right'
  72. // }
  73. // })
  74. // Vue.use(AMap)
  75. // AMap.initAMapApiLoader({
  76. // // 高德的key
  77. // key: '5894bf90997454b0df3c3d60cab12f64',
  78. // plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch']
  79. // })
  80. import '@/utils/time.js'
  81. import { getIPAdd } from '@/utils/lbs.js'
  82. getIPAdd()
  83. .then(res => {
  84. Vue.prototype.$IpAdd = res.data
  85. })
  86. .catch(err => {})
  87. // 成功/错误提示
  88. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  89. Vue.prototype.$successMsg = successMsg
  90. Vue.prototype.$errorMsg = errorMsg
  91. Vue.prototype.$warningNotify = warningNotify
  92. Vue.prototype.$checkBtnRole = checkBtnRole
  93. Vue.prototype.$getSummaries = getSummaries
  94. Vue.prototype.$numToFixed = numToFixed
  95. Vue.prototype.$startLoading = startLoading
  96. Vue.prototype.$endLoading = endLoading
  97. Vue.prototype.$restrict = function (...codes) {
  98. var roles = this.$route.meta.roles || []
  99. for (var code of codes) {
  100. if (roles.includes(code)) {
  101. return true
  102. }
  103. }
  104. return false
  105. }
  106. // 自定义组件
  107. import ExportButton from '@/components/Common/export-button.vue'
  108. Vue.component('ExportButton', ExportButton)
  109. import ImportButton from '@/components/Common/import-button.vue'
  110. Vue.component('ImportButton', ImportButton)
  111. import CopyButton from '@/components/Common/copy-button.vue'
  112. Vue.component('CopyButton', CopyButton)
  113. import Collapse from '@/components/Common/collapse'
  114. Vue.component('Collapse', Collapse)
  115. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_OSS;
  116. Vue.prototype.$xdocUrl = 'https://pgxtadm.greeapps.com/preview/onlinePreview?url='
  117. Vue.prototype.$findElem = findElem;
  118. Vue.prototype.$deleteEmptyObj = deleteEmptyObj;
  119. /**
  120. * If you don't want to use mock-server
  121. * you want to use MockJs for mock api
  122. * you can execute: mockXHR()
  123. *
  124. * Currently MockJs will be used in the production environment,
  125. * please remove it before going online ! ! !
  126. */
  127. if (process.env.NODE_ENV === 'production') {
  128. const { mockXHR } = require('../mock')
  129. mockXHR()
  130. }
  131. // set ElementUI lang to EN
  132. // Vue.use(ElementUI, { locale })
  133. // 如果想要中文版 element-ui,按如下方式声明
  134. Vue.use(ElementUI)
  135. // register global utility filters
  136. Object.keys(filters).forEach(key => {
  137. Vue.filter(key, filters[key])
  138. })
  139. Object.keys(directives).forEach(key => {
  140. Vue.directive(key, directives[key])
  141. })
  142. Vue.config.productionTip = false
  143. new Vue({
  144. el: '#app',
  145. router,
  146. store,
  147. render: h => h(App)
  148. })