main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. postTwo,
  18. get
  19. } from '@/utils/request'
  20. // svg图标
  21. import 'virtual:svg-icons-register'
  22. import SvgIcon from '@/components/SvgIcon'
  23. import elementIcons from '@/components/SvgIcon/svgicon'
  24. import './permission' // permission control
  25. import {
  26. useDict
  27. } from '@/utils/dict'
  28. import {
  29. parseTime,
  30. resetForm,
  31. addDateRange,
  32. handleTree,
  33. selectDictLabel,
  34. selectDictLabels
  35. } from '@/utils/ruoyi'
  36. import {
  37. dictDataEcho,
  38. dictValueLabel,
  39. moneyFormat,
  40. calculationWeek,
  41. getDict,
  42. getDictOne,
  43. getPdf,
  44. getPdfTransverseA4,
  45. translateIntoEnglish,
  46. random,
  47. deepClone,
  48. timeInterval,
  49. compareTime
  50. } from '@/utils/util'
  51. // 分页组件
  52. import Pagination from '@/components/Pagination'
  53. // 自定义表格工具组件
  54. import RightToolbar from '@/components/RightToolbar'
  55. // 文件上传组件
  56. import FileUpload from "@/components/FileUpload"
  57. // 图片上传组件
  58. import ImageUpload from "@/components/ImageUpload"
  59. // 图片预览组件
  60. import ImagePreview from "@/components/ImagePreview"
  61. // 自定义树选择组件
  62. import TreeSelect from '@/components/TreeSelect'
  63. // 字典标签组件
  64. import DictTag from '@/components/DictTag'
  65. // 多语言
  66. import i18n from "@/lang/index";
  67. // 打印
  68. import print from "vue3-print-nb"
  69. const app = createApp(App)
  70. console.log(i18n.global.t('login.welcomeToLogin'))
  71. // 全局方法挂载
  72. app.config.globalProperties.useDict = useDict
  73. app.config.globalProperties.get = get
  74. app.config.globalProperties.post = post
  75. app.config.globalProperties.postTwo = postTwo
  76. app.config.globalProperties.download = download
  77. app.config.globalProperties.parseTime = parseTime
  78. app.config.globalProperties.resetForm = resetForm
  79. app.config.globalProperties.handleTree = handleTree
  80. app.config.globalProperties.addDateRange = addDateRange
  81. app.config.globalProperties.selectDictLabel = selectDictLabel
  82. app.config.globalProperties.selectDictLabels = selectDictLabels
  83. app.config.globalProperties.t = i18n.global.t
  84. //字典回显
  85. app.config.globalProperties.dictDataEcho = dictDataEcho
  86. app.config.globalProperties.dictValueLabel = dictValueLabel
  87. app.config.globalProperties.moneyFormat = moneyFormat
  88. app.config.globalProperties.calculationWeek = calculationWeek
  89. app.config.globalProperties.getDict = getDict
  90. app.config.globalProperties.getDictOne = getDictOne
  91. app.config.globalProperties.getPdf = getPdf
  92. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
  93. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
  94. app.config.globalProperties.random = random
  95. app.config.globalProperties.deepClone = deepClone
  96. app.config.globalProperties.timeInterval = timeInterval
  97. app.config.globalProperties.compareTime = compareTime
  98. // 全局组件挂载
  99. app.component('DictTag', DictTag)
  100. app.component('Pagination', Pagination)
  101. app.component('TreeSelect', TreeSelect)
  102. app.component('FileUpload', FileUpload)
  103. app.component('ImageUpload', ImageUpload)
  104. app.component('ImagePreview', ImagePreview)
  105. app.component('RightToolbar', RightToolbar)
  106. app.use(router)
  107. app.use(store)
  108. app.use(plugins)
  109. app.use(i18n)
  110. app.use(elementIcons)
  111. app.use(print)
  112. app.component('svg-icon', SvgIcon)
  113. directive(app)
  114. // 使用element-plus 并且设置全局的大小
  115. app.use(ElementPlus, {
  116. locale: locale,
  117. // 支持 large、default、small
  118. size: Cookies.get('size') || 'default'
  119. })
  120. app.mount('#app')