main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 '@/utils/table2excel'
  8. import '@/assets/styles/index.scss' // global css
  9. import App from './App'
  10. import store from './store'
  11. import router from './router'
  12. import directive from './directive' // directive
  13. // 注册指令
  14. import plugins from './plugins' // plugins
  15. import {
  16. download,
  17. post,
  18. postTwo,
  19. get
  20. } from '@/utils/request'
  21. // svg图标
  22. import 'virtual:svg-icons-register'
  23. import SvgIcon from '@/components/SvgIcon'
  24. import elementIcons from '@/components/SvgIcon/svgicon'
  25. import './permission' // permission control
  26. import {
  27. useDict
  28. } from '@/utils/dict'
  29. import {
  30. parseTime,
  31. resetForm,
  32. addDateRange,
  33. handleTree,
  34. selectDictLabel,
  35. selectDictLabels
  36. } from '@/utils/ruoyi'
  37. import {
  38. dictDataEcho,
  39. dictValueLabel,
  40. moneyFormat,
  41. calculationWeek,
  42. getDict,
  43. getDictOne,
  44. getPdf,
  45. getPdfTransverseA4,
  46. translateIntoEnglish,
  47. random,
  48. deepClone,
  49. timeInterval,
  50. compareTime,
  51. getImgBase64
  52. } from '@/utils/util'
  53. // 分页组件
  54. import Pagination from '@/components/Pagination'
  55. // 自定义表格工具组件
  56. import RightToolbar from '@/components/RightToolbar'
  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. app.config.globalProperties.getImgBase64 = getImgBase64
  99. // 全局组件挂载
  100. app.component('DictTag', DictTag)
  101. app.component('Pagination', Pagination)
  102. app.component('TreeSelect', TreeSelect)
  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')