main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { createApp } from 'vue'
  2. import Cookies from 'js-cookie'
  3. import ElementPlus from 'element-plus'
  4. import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
  5. import '@/assets/styles/index.scss' // global css
  6. import App from './App'
  7. import store from './store'
  8. import router from './router'
  9. import directive from './directive' // directive
  10. // 注册指令
  11. import plugins from './plugins' // plugins
  12. import { download } from '@/utils/request'
  13. // svg图标
  14. import 'virtual:svg-icons-register'
  15. import SvgIcon from '@/components/SvgIcon'
  16. import elementIcons from '@/components/SvgIcon/svgicon'
  17. import './permission' // permission control
  18. import { useDict } from '@/utils/dict'
  19. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
  20. // 分页组件
  21. import Pagination from '@/components/Pagination'
  22. // 自定义表格工具组件
  23. import RightToolbar from '@/components/RightToolbar'
  24. // 文件上传组件
  25. import FileUpload from "@/components/FileUpload"
  26. // 图片上传组件
  27. import ImageUpload from "@/components/ImageUpload"
  28. // 图片预览组件
  29. import ImagePreview from "@/components/ImagePreview"
  30. // 自定义树选择组件
  31. import TreeSelect from '@/components/TreeSelect'
  32. // 字典标签组件
  33. import DictTag from '@/components/DictTag'
  34. const app = createApp(App)
  35. // 全局方法挂载
  36. app.config.globalProperties.useDict = useDict
  37. app.config.globalProperties.download = download
  38. app.config.globalProperties.parseTime = parseTime
  39. app.config.globalProperties.resetForm = resetForm
  40. app.config.globalProperties.handleTree = handleTree
  41. app.config.globalProperties.addDateRange = addDateRange
  42. app.config.globalProperties.selectDictLabel = selectDictLabel
  43. app.config.globalProperties.selectDictLabels = selectDictLabels
  44. // 全局组件挂载
  45. app.component('DictTag', DictTag)
  46. app.component('Pagination', Pagination)
  47. app.component('TreeSelect', TreeSelect)
  48. app.component('FileUpload', FileUpload)
  49. app.component('ImageUpload', ImageUpload)
  50. app.component('ImagePreview', ImagePreview)
  51. app.component('RightToolbar', RightToolbar)
  52. app.use(router)
  53. app.use(store)
  54. app.use(plugins)
  55. app.use(elementIcons)
  56. app.component('svg-icon', SvgIcon)
  57. directive(app)
  58. // 使用element-plus 并且设置全局的大小
  59. app.use(ElementPlus, {
  60. locale: locale,
  61. // 支持 large、default、small
  62. size: Cookies.get('size') || 'default'
  63. })
  64. app.mount('#app')