main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import Element from 'element-ui'
  4. import AFTableColumn from 'af-table-column'
  5. import './assets/fonts/iconfont.css'
  6. import './assets/styles/element-variables.scss'
  7. import '@/assets/styles/index.scss' // global css
  8. import '@/assets/styles/ruoyi.scss' // ruoyi css
  9. import App from './App'
  10. import store from './store'
  11. import api from '@/api/api'
  12. import upload from '@/utils/uploadFile'
  13. import router from './router'
  14. import directive from './directive' //directive
  15. import plugins from './plugins' // plugins
  16. import './assets/icons' // icon
  17. import './permission' // permission control
  18. import { getDicts } from "@/api/system/dict/data";
  19. import { getConfigKey } from "@/api/system/config";
  20. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
  21. // 通用弹窗
  22. import BaseDialog from "@/components/BaseDialog";
  23. // 分页组件
  24. import Pagination from "@/components/Paginations";
  25. // 自定义表格工具组件
  26. import RightToolbar from "@/components/RightToolbar"
  27. // 富文本组件
  28. import Editor from "@/components/Editor"
  29. // 文件上传组件
  30. import FileUpload from "@/components/FileUpload"
  31. // 图片上传组件
  32. import ImageUpload from "@/components/ImageUpload"
  33. // 字典标签组件
  34. import DictTag from '@/components/DictTag'
  35. // 头部标签组件
  36. import VueMeta from 'vue-meta'
  37. // 字典数据组件
  38. import DictData from '@/components/DictData'
  39. import methodsTools from '@/utils/methodsTool'
  40. import bus from '@/utils/eventBus'
  41. // 全局方法挂载
  42. Vue.prototype.$store = store
  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.handleTree = handleTree
  51. Vue.prototype.$api = api
  52. Vue.prototype.$upload = upload
  53. Vue.prototype.$methodsTools = methodsTools
  54. Vue.prototype.$bus = bus
  55. // 全局组件挂载
  56. Vue.component('DictTag', DictTag)
  57. Vue.component('Pagination', Pagination)
  58. Vue.component('BaseDialog', BaseDialog)
  59. Vue.component('RightToolbar', RightToolbar)
  60. Vue.component('Editor', Editor)
  61. Vue.component('FileUpload', FileUpload)
  62. Vue.component('ImageUpload', ImageUpload)
  63. const fontRate = {
  64. CHAR_RATE: 1.1, // 汉字比率
  65. NUM_RATE: 0.65, // 数字
  66. OTHER_RATE: 0.8 // 除汉字和数字以外的字符的比率
  67. }
  68. const fontSize = 16
  69. // 注册组件
  70. Vue.use(AFTableColumn, { fontRate, fontSize })
  71. Vue.use(directive)
  72. Vue.use(plugins)
  73. Vue.use(VueMeta)
  74. DictData.install()
  75. /**
  76. * If you don't want to use mock-server
  77. * you want to use MockJs for mock api
  78. * you can execute: mockXHR()
  79. *
  80. * Currently MockJs will be used in the production environment,
  81. * please remove it before going online! ! !
  82. */
  83. Vue.use(Element, {
  84. size: Cookies.get('size') || 'medium' // set element-ui default size
  85. })
  86. Vue.config.productionTip = false
  87. new Vue({
  88. el: '#app',
  89. router,
  90. store,
  91. render: h => h(App)
  92. })