main.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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/ruoyi.scss' // ruoyi css
  7. import '../public/print-lock.css'
  8. import App from './App'
  9. import store from './store'
  10. import router from './router'
  11. import directive from './directive' // directive
  12. import plugins from './plugins' // plugins
  13. import { download } from '@/utils/request'
  14. import './assets/icons' // icon
  15. import './permission' // permission control
  16. import { getDicts } from "@/api/system/dict/data";
  17. import { getConfigKey } from "@/api/system/config";
  18. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
  19. import { checkPermi } from './utils/permission';
  20. // 分页组件
  21. import Pagination from "@/components/Pagination";
  22. // 自定义表格工具组件
  23. import RightToolbar from "@/components/RightToolbar"
  24. // 富文本组件
  25. import Editor from "@/components/Editor"
  26. // 文件上传组件
  27. import FileUpload from "@/components/FileUpload"
  28. // 图片上传组件
  29. import ImageUpload from "@/components/ImageUpload"
  30. // 图片预览组件
  31. import ImagePreview from "@/components/ImagePreview"
  32. // 字典标签组件
  33. import DictTag from '@/components/DictTag'
  34. // 头部标签组件
  35. import VueMeta from 'vue-meta'
  36. // 字典数据组件
  37. import DictData from '@/components/DictData'
  38. import webSite from '@/config/website'
  39. // import debounce from '@/components/directives/debounce';
  40. Vue.prototype.website = webSite
  41. // Vue.prototype.debounce = debounce
  42. // 全局方法挂载
  43. Vue.prototype.getDicts = getDicts
  44. Vue.prototype.getConfigKey = getConfigKey
  45. Vue.prototype.parseTime = parseTime
  46. Vue.prototype.resetForm = resetForm
  47. Vue.prototype.addDateRange = addDateRange
  48. Vue.prototype.selectDictLabel = selectDictLabel
  49. Vue.prototype.selectDictLabels = selectDictLabels
  50. Vue.prototype.download = download
  51. Vue.prototype.handleTree = handleTree
  52. Vue.prototype.checkPermission = checkPermi
  53. // 全局组件挂载
  54. Vue.component('DictTag', DictTag)
  55. Vue.component('Pagination', Pagination)
  56. Vue.component('RightToolbar', RightToolbar)
  57. Vue.component('Editor', Editor)
  58. Vue.component('FileUpload', FileUpload)
  59. Vue.component('ImageUpload', ImageUpload)
  60. Vue.component('ImagePreview', ImagePreview)
  61. // 解决el-radio报错
  62. Vue.directive('removeAriaHidden', {
  63. bind(el, binding) {
  64. let ariaEls = el.querySelectorAll('.el-radio__original');
  65. ariaEls.forEach((item) => {
  66. item.removeAttribute('aria-hidden');
  67. });
  68. }
  69. });
  70. Vue.use(directive)
  71. Vue.use(plugins)
  72. Vue.use(VueMeta)
  73. DictData.install()
  74. /**
  75. * If you don't want to use mock-server
  76. * you want to use MockJs for mock api
  77. * you can execute: mockXHR()
  78. *
  79. * Currently MockJs will be used in the production environment,
  80. * please remove it before going online! ! !
  81. */
  82. //在main.js中
  83. // 提交以后禁用按钮一段时间,防止重复提交
  84. Vue.directive('noMoreClick', {
  85. inserted(el, binding) {
  86. el.addEventListener('click', e => {
  87. el.classList.add('is-disabled')
  88. el.disabled = true
  89. setTimeout(() => {
  90. el.disabled = false
  91. el.classList.remove('is-disabled')
  92. }, 1000)//我这里设置的是2000毫秒也就是2秒
  93. })
  94. }
  95. })
  96. Vue.use(Element, {
  97. size: Cookies.get('size') || 'medium' // set element-ui default size
  98. })
  99. Vue.config.productionTip = false
  100. new Vue({
  101. el: '#app',
  102. router,
  103. store,
  104. render: h => h(App)
  105. })