main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 ImageUpload from "@/components/ImageUpload"
  57. // 图片预览组件
  58. import ImagePreview from "@/components/ImagePreview"
  59. // 自定义树选择组件
  60. import TreeSelect from '@/components/TreeSelect'
  61. // 字典标签组件
  62. import DictTag from '@/components/DictTag'
  63. // 多语言
  64. import i18n from "@/lang/index";
  65. // 打印
  66. import print from "vue3-print-nb"
  67. const app = createApp(App)
  68. console.log(i18n.global.t('login.welcomeToLogin'))
  69. // 全局方法挂载
  70. app.config.globalProperties.useDict = useDict
  71. app.config.globalProperties.get = get
  72. app.config.globalProperties.post = post
  73. app.config.globalProperties.postTwo = postTwo
  74. app.config.globalProperties.download = download
  75. app.config.globalProperties.parseTime = parseTime
  76. app.config.globalProperties.resetForm = resetForm
  77. app.config.globalProperties.handleTree = handleTree
  78. app.config.globalProperties.addDateRange = addDateRange
  79. app.config.globalProperties.selectDictLabel = selectDictLabel
  80. app.config.globalProperties.selectDictLabels = selectDictLabels
  81. app.config.globalProperties.t = i18n.global.t
  82. //字典回显
  83. app.config.globalProperties.dictDataEcho = dictDataEcho
  84. app.config.globalProperties.dictValueLabel = dictValueLabel
  85. app.config.globalProperties.moneyFormat = moneyFormat
  86. app.config.globalProperties.calculationWeek = calculationWeek
  87. app.config.globalProperties.getDict = getDict
  88. app.config.globalProperties.getDictOne = getDictOne
  89. app.config.globalProperties.getPdf = getPdf
  90. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
  91. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
  92. app.config.globalProperties.random = random
  93. app.config.globalProperties.deepClone = deepClone
  94. app.config.globalProperties.timeInterval = timeInterval
  95. app.config.globalProperties.compareTime = compareTime
  96. // 全局组件挂载
  97. app.component('DictTag', DictTag)
  98. app.component('Pagination', Pagination)
  99. app.component('TreeSelect', TreeSelect)
  100. app.component('ImageUpload', ImageUpload)
  101. app.component('ImagePreview', ImagePreview)
  102. app.component('RightToolbar', RightToolbar)
  103. app.use(router)
  104. app.use(store)
  105. app.use(plugins)
  106. app.use(i18n)
  107. app.use(elementIcons)
  108. app.use(print)
  109. app.component('svg-icon', SvgIcon)
  110. directive(app)
  111. // 使用element-plus 并且设置全局的大小
  112. app.use(ElementPlus, {
  113. locale: locale,
  114. // 支持 large、default、small
  115. size: Cookies.get('size') || 'default'
  116. })
  117. app.mount('#app')