main.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import {
  2. createApp
  3. } from 'vue'
  4. import Cookies from 'js-cookie'
  5. import ElementPlus from 'element-plus'
  6. import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
  7. import '@/assets/styles/index.scss' // global css
  8. import App from './App'
  9. import store from './store'
  10. import router from './router'
  11. import directive from './directive' // directive
  12. // 注册指令
  13. import plugins from './plugins' // plugins
  14. import {
  15. download,
  16. post,
  17. get
  18. } from '@/utils/request'
  19. // svg图标
  20. import 'virtual:svg-icons-register'
  21. import SvgIcon from '@/components/SvgIcon'
  22. import elementIcons from '@/components/SvgIcon/svgicon'
  23. import './permission' // permission control
  24. import {
  25. useDict
  26. } from '@/utils/dict'
  27. import {
  28. parseTime,
  29. resetForm,
  30. addDateRange,
  31. handleTree,
  32. selectDictLabel,
  33. selectDictLabels
  34. } from '@/utils/ruoyi'
  35. import {
  36. dictDataEcho,
  37. dictValueLabel,
  38. moneyFormat,
  39. calculationWeek,
  40. getDict,
  41. getDictOne,
  42. getPdf,
  43. getPdfTransverseA4,
  44. translateIntoEnglish,
  45. random,
  46. deepClone
  47. } from '@/utils/util'
  48. // 分页组件
  49. import Pagination from '@/components/Pagination'
  50. // 自定义表格工具组件
  51. import RightToolbar from '@/components/RightToolbar'
  52. // 文件上传组件
  53. import FileUpload from "@/components/FileUpload"
  54. // 图片上传组件
  55. import ImageUpload from "@/components/ImageUpload"
  56. // 图片预览组件
  57. import ImagePreview from "@/components/ImagePreview"
  58. // 自定义树选择组件
  59. import TreeSelect from '@/components/TreeSelect'
  60. // 字典标签组件
  61. import DictTag from '@/components/DictTag'
  62. // 多语言
  63. import i18n from "@/lang/index";
  64. const app = createApp(App)
  65. // 全局方法挂载
  66. app.config.globalProperties.useDict = useDict
  67. app.config.globalProperties.get = get
  68. app.config.globalProperties.post = post
  69. app.config.globalProperties.download = download
  70. app.config.globalProperties.parseTime = parseTime
  71. app.config.globalProperties.resetForm = resetForm
  72. app.config.globalProperties.handleTree = handleTree
  73. app.config.globalProperties.addDateRange = addDateRange
  74. app.config.globalProperties.selectDictLabel = selectDictLabel
  75. app.config.globalProperties.selectDictLabels = selectDictLabels
  76. //字典回显
  77. app.config.globalProperties.dictDataEcho = dictDataEcho
  78. app.config.globalProperties.dictValueLabel = dictValueLabel
  79. app.config.globalProperties.moneyFormat = moneyFormat
  80. app.config.globalProperties.calculationWeek = calculationWeek
  81. app.config.globalProperties.getDict = getDict
  82. app.config.globalProperties.getDictOne = getDictOne
  83. app.config.globalProperties.getPdf = getPdf
  84. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
  85. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
  86. app.config.globalProperties.random = random
  87. app.config.globalProperties.deepClone = deepClone
  88. // 全局组件挂载
  89. app.component('DictTag', DictTag)
  90. app.component('Pagination', Pagination)
  91. app.component('TreeSelect', TreeSelect)
  92. app.component('FileUpload', FileUpload)
  93. app.component('ImageUpload', ImageUpload)
  94. app.component('ImagePreview', ImagePreview)
  95. app.component('RightToolbar', RightToolbar)
  96. app.use(router)
  97. app.use(store)
  98. app.use(plugins)
  99. app.use(i18n)
  100. app.use(elementIcons)
  101. app.component('svg-icon', SvgIcon)
  102. directive(app)
  103. // 使用element-plus 并且设置全局的大小
  104. app.use(ElementPlus, {
  105. locale: locale,
  106. // 支持 large、default、small
  107. size: Cookies.get('size') || 'default'
  108. })
  109. app.mount('#app')