main.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import Element from 'element-ui'
  4. import './assets/styles/element-variables.scss'
  5. import '@/assets/styles/index.scss' // global css
  6. import '@/assets/styles/supervision.scss' // supervision css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' //directive
  11. import plugins from './plugins' // plugins
  12. // 引入jquery
  13. import $ from "jquery";
  14. window.$ = $;
  15. window.jQuery = $;
  16. export default $;
  17. import './assets/icons' // icon
  18. import './permission' // permission control
  19. import { getDicts } from "@/api/system/dict/data";
  20. import { getConfigKey } from "@/api/system/config";
  21. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree, getNowWeek } from "@/utils/supervision";
  22. // 分页组件
  23. import Pagination from "@/components/Pagination";
  24. // 自定义表格工具组件
  25. import RightToolbar from "@/components/RightToolbar"
  26. // 富文本组件
  27. import Editor from "@/components/Editor"
  28. // 文件上传组件
  29. import FileUpload from "@/components/FileUpload"
  30. // 图片上传组件
  31. import ImageUpload from "@/components/ImageUpload"
  32. // 字典标签组件
  33. import DictTag from '@/components/DictTag'
  34. // 头部标签组件
  35. import VueMeta from 'vue-meta'
  36. // 字典数据组件
  37. import DictData from '@/components/DictData'
  38. // 公共样式
  39. import '@/assets/styles/global.css'
  40. // 全局挂载 VueQuillEditor
  41. import VueQuillEditor from 'vue-quill-editor'
  42. import 'quill/dist/quill.core.css'
  43. import 'quill/dist/quill.snow.css'
  44. import 'quill/dist/quill.bubble.css'
  45. import '@/utils/lodJs.js'
  46. // 引入echarts
  47. import echarts from 'echarts'
  48. // 全局方法挂载
  49. Vue.prototype.getDicts = getDicts
  50. Vue.prototype.getConfigKey = getConfigKey
  51. Vue.prototype.parseTime = parseTime
  52. Vue.prototype.resetForm = resetForm
  53. Vue.prototype.addDateRange = addDateRange
  54. Vue.prototype.selectDictLabel = selectDictLabel
  55. Vue.prototype.selectDictLabels = selectDictLabels
  56. Vue.prototype.handleTree = handleTree
  57. Vue.prototype.getNowWeek = getNowWeek
  58. // originVal 后台返回的中国标准时间
  59. Vue.filter('dataFormat', originVal => {
  60. const dt = new Date(originVal)
  61. if (originVal) {
  62. const y = dt.getFullYear()
  63. const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  64. const d = (dt.getDate() + '').padStart(2, '0')
  65. return `${y}-${m}-${d}`
  66. }
  67. })
  68. import dataV from '@jiaminghi/data-view'
  69. Vue.use(dataV)
  70. // 全局组件挂载
  71. Vue.component('DictTag', DictTag)
  72. Vue.component('Pagination', Pagination)
  73. Vue.component('RightToolbar', RightToolbar)
  74. Vue.component('Editor', Editor)
  75. Vue.component('FileUpload', FileUpload)
  76. Vue.component('ImageUpload', ImageUpload)
  77. Vue.use(directive)
  78. Vue.use(plugins)
  79. Vue.use(VueMeta)
  80. Vue.use(VueQuillEditor)
  81. DictData.install()
  82. /**
  83. * If you don't want to use mock-server
  84. * you want to use MockJs for mock api
  85. * you can execute: mockXHR()
  86. *
  87. * Currently MockJs will be used in the production environment,
  88. * please remove it before going online! ! !
  89. */
  90. Vue.use(Element, {
  91. size: Cookies.get('size') || 'medium' // set element-ui default size
  92. })
  93. Vue.config.productionTip = false
  94. new Vue({
  95. el: '#app',
  96. router,
  97. store,
  98. render: h => h(App)
  99. })
  100. const on = Vue.prototype.$on
  101. Vue.prototype.$on = function (event, func) {
  102. let timer;
  103. let flag = true;
  104. let newFunc = func
  105. if (event == 'click') {
  106. newFunc = function () {
  107. if(flag) {
  108. func.apply(this, arguments)
  109. flag = false
  110. }
  111. clearTimeout(timer)
  112. timer = setTimeout(function () {
  113. flag = true
  114. }, 3000)
  115. }
  116. }
  117. on.call(this, event, newFunc)
  118. }