main.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 VueI18n from 'vue-i18n'
  10. // import GlobalTextProcessor from './global-text-processor' // 导入插件
  11. // Vue.use(VueI18n)
  12. // Vue.use(GlobalTextProcessor) // 注册插件
  13. // const i18n = new VueI18n({
  14. // locale: 'ar'
  15. // // messages
  16. // })
  17. import ElementUI from '@zjlib/element-ui2'
  18. import '@zjlib/element-ui2/lib/theme-chalk/index.css'
  19. import VueQuillEditor from 'vue-quill-editor'
  20. // require styles
  21. import 'quill/dist/quill.core.css'
  22. import 'quill/dist/quill.snow.css'
  23. import 'quill/dist/quill.bubble.css'
  24. Vue.use(VueQuillEditor /* { default global options } */)
  25. import dataV from '@jiaminghi/data-view'
  26. Vue.use(dataV)
  27. import VQuillEditor from '@/components/v-quill-editor'
  28. Vue.component('v-quill-editor', VQuillEditor)
  29. import { Loading } from '@zjlib/element-ui2'
  30. let loading
  31. function startLoading() {
  32. loading = Loading.service({
  33. lock: true,
  34. text: '拼命加载中...',
  35. spinner: 'el-icon-loading',
  36. customClass: '.app-container'
  37. })
  38. }
  39. function endLoading() {
  40. loading.close()
  41. }
  42. import * as echarts from 'echarts'
  43. Vue.prototype.$echarts = echarts
  44. import '@/styles/index.scss' // global css
  45. import App from './App'
  46. import store from './store'
  47. import router from './router'
  48. import '@/icons' // icon
  49. import '@/permission' // permission control
  50. import * as filters from './filters' // global filters
  51. import directives from './directives'
  52. window._AMapSecurityConfig = {
  53. serviceHost: 'https://jiasm.zfire.top/' + '_AMapService'
  54. }
  55. import '@zjlib/element-plugins/dest/element-plugins.css'
  56. import ElementPlugins, { AMap } from '@zjlib/element-plugins'
  57. Vue.use(ElementPlugins, {
  58. // 表单页面表单属性配置
  59. formAttributes: {
  60. 'label-position': 'right'
  61. }
  62. // // 操作记录配置
  63. // operationRecord: function (options) {
  64. // // console.log(options.meta.moduleId)
  65. // // return new Promise((r, j) => {
  66. // // r([[], []])
  67. // // })
  68. // }
  69. })
  70. Vue.use(AMap)
  71. AMap.initAMapApiLoader({
  72. // 高德的key
  73. key: 'df9bfabcba60cc6e7ad45ae9923a682d',
  74. version: '2.0',
  75. plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
  76. })
  77. // // 本地引用;
  78. // import ElementPlugins, { AMap } from '@packages'
  79. // Vue.use(ElementPlugins, {
  80. // formAttributes: {
  81. // 'label-position': 'right'
  82. // }
  83. // })
  84. // Vue.use(AMap)
  85. // AMap.initAMapApiLoader({
  86. // // 高德的key
  87. // key: 'df9bfabcba60cc6e7ad45ae9923a682d',
  88. // plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch']
  89. // })
  90. import '@/utils/time.js'
  91. import { getIPAdd } from '@/utils/lbs.js'
  92. getIPAdd()
  93. .then(res => {
  94. Vue.prototype.$IpAdd = res.data
  95. })
  96. .catch(err => {})
  97. // 成功/错误提示
  98. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  99. Vue.prototype.$successMsg = successMsg
  100. Vue.prototype.$errorMsg = errorMsg
  101. Vue.prototype.$warningNotify = warningNotify
  102. Vue.prototype.$checkBtnRole = checkBtnRole
  103. Vue.prototype.$getSummaries = getSummaries
  104. Vue.prototype.$numToFixed = numToFixed
  105. Vue.prototype.$startLoading = startLoading
  106. Vue.prototype.$endLoading = endLoading
  107. Vue.prototype.$restrict = function (...codes) {
  108. var roles = this.$route.meta.roles || []
  109. for (var code of codes) {
  110. if (roles.includes(code)) {
  111. return true
  112. }
  113. }
  114. return false
  115. }
  116. // 自定义组件
  117. import ExportButton from '@/components/Common/export-button.vue'
  118. Vue.component('ExportButton', ExportButton)
  119. import ImportButton from '@/components/Common/import-button.vue'
  120. Vue.component('ImportButton', ImportButton)
  121. import CopyButton from '@/components/Common/copy-button.vue'
  122. Vue.component('CopyButton', CopyButton)
  123. import Collapse from '@/components/Common/collapse'
  124. Vue.component('Collapse', Collapse)
  125. Vue.prototype.$xdocUrl = 'https://pgxtadm.greeapps.com/preview/onlinePreview?url='
  126. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_API + 'img/get?key='
  127. Vue.prototype.$showImgUrl = function (url) {
  128. try {
  129. const { pathname } = new URL(url)
  130. if (pathname.startsWith('/')) {
  131. return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname.substring(1)}`
  132. }
  133. return `${process.env.VUE_APP_BASE_API}img/get?key=${pathname}`
  134. } catch (error) {
  135. return url
  136. }
  137. }
  138. Vue.prototype.$findElem = findElem
  139. Vue.prototype.$deleteEmptyObj = deleteEmptyObj
  140. /**
  141. * If you don't want to use mock-server
  142. * you want to use MockJs for mock api
  143. * you can execute: mockXHR()
  144. *
  145. * Currently MockJs will be used in the production environment,
  146. * please remove it before going online ! ! !
  147. */
  148. if (process.env.NODE_ENV === 'production') {
  149. const { mockXHR } = require('../mock')
  150. mockXHR()
  151. }
  152. // set ElementUI lang to EN
  153. // Vue.use(ElementUI, { locale })
  154. // 如果想要中文版 element-ui,按如下方式声明
  155. Vue.use(ElementUI)
  156. import { Message } from 'element-ui'
  157. //定义一个新的Message方法,多传入一个offset参数
  158. const $message = options => {
  159. return Message({
  160. ...options,
  161. offset: 80
  162. })
  163. }
  164. //重写方法,将offset写入options
  165. ;['success', 'warning', 'info', 'error'].forEach(type => {
  166. $message[type] = options => {
  167. if (typeof options === 'string') {
  168. options = {
  169. message: options,
  170. offset: 80
  171. }
  172. }
  173. options.type = type
  174. return Message(options)
  175. }
  176. })
  177. //将$message挂载到this上
  178. Vue.prototype.$message = $message
  179. //不加这行代码运行this.$message.closeAll时会报错
  180. Vue.prototype.$message.closeAll = Message.closeAll
  181. // register global utility filters
  182. Object.keys(filters).forEach(key => {
  183. Vue.filter(key, filters[key])
  184. })
  185. Object.keys(directives).forEach(key => {
  186. Vue.directive(key, directives[key])
  187. })
  188. Vue.config.productionTip = false
  189. new Vue({
  190. el: '#app',
  191. router,
  192. store,
  193. // i18n,
  194. render: h => h(App)
  195. })