main.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { createApp } from 'vue'
  2. import Cookies from 'js-cookie'
  3. import ElementPlus from 'element-plus'
  4. import 'element-plus/dist/index.css'
  5. import locale from 'element-plus/es/locale/lang/zh-cn'
  6. import '@/assets/styles/index.scss' // global css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' // directive
  11. // 注册指令
  12. import plugins from './plugins' // plugins
  13. import { download } from '@/utils/request'
  14. // svg图标
  15. import 'virtual:svg-icons-register'
  16. import SvgIcon from '@/components/SvgIcon'
  17. import elementIcons from '@/components/SvgIcon/svgicon'
  18. import './permission' // permission control
  19. import { useDict } from '@/utils/dict'
  20. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
  21. import { hoursToSeconds } from '@/utils/hts.js'
  22. import { playTime } from '@/utils/playTime.js'
  23. // 分页组件
  24. import Pagination from '@/components/Pagination'
  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 ImagePreview from "@/components/ImagePreview"
  35. // 自定义树选择组件
  36. import TreeSelect from '@/components/TreeSelect'
  37. // 字典标签组件
  38. import DictTag from '@/components/DictTag'
  39. // 自定义文件上传组件
  40. import Upload from "@/components/Upload"
  41. // 拖拽组件
  42. import draggable from 'vuedraggable'
  43. const app = createApp(App)
  44. // 全局方法挂载
  45. app.config.globalProperties.useDict = useDict
  46. app.config.globalProperties.download = download
  47. app.config.globalProperties.parseTime = parseTime
  48. app.config.globalProperties.resetForm = resetForm
  49. app.config.globalProperties.handleTree = handleTree
  50. app.config.globalProperties.addDateRange = addDateRange
  51. app.config.globalProperties.selectDictLabel = selectDictLabel
  52. app.config.globalProperties.selectDictLabels = selectDictLabels
  53. app.config.globalProperties.hoursToSeconds = hoursToSeconds
  54. app.config.globalProperties.playTime = playTime
  55. // 全局组件挂载
  56. app.component('DictTag', DictTag)
  57. app.component('Pagination', Pagination)
  58. app.component('TreeSelect', TreeSelect)
  59. app.component('FileUpload', FileUpload)
  60. app.component('ImageUpload', ImageUpload)
  61. app.component('ImagePreview', ImagePreview)
  62. app.component('RightToolbar', RightToolbar)
  63. app.component('Editor', Editor)
  64. app.component('CustomUpload', Upload)
  65. app.component('draggable', draggable)
  66. app.use(router)
  67. app.use(store)
  68. app.use(plugins)
  69. app.use(elementIcons)
  70. app.component('svg-icon', SvgIcon)
  71. directive(app)
  72. // 使用element-plus 并且设置全局的大小
  73. app.use(ElementPlus, {
  74. locale: locale,
  75. // 支持 large、default、small
  76. size: Cookies.get('size') || 'default'
  77. })
  78. app.mount('#app')