main.js 3.7 KB

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