main.js 3.8 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. downloadFile,
  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. generateAuthorization
  52. } from '@/utils/util'
  53. // 分页组件
  54. import Pagination from '@/components/Pagination'
  55. // 自定义表格工具组件
  56. import RightToolbar from '@/components/RightToolbar'
  57. // 文件上传组件
  58. import FileUpload from "@/components/FileUpload"
  59. // 图片上传组件
  60. import ImageUpload from "@/components/ImageUpload"
  61. // 图片预览组件
  62. import ImagePreview from "@/components/ImagePreview"
  63. // 自定义树选择组件
  64. import TreeSelect from '@/components/TreeSelect'
  65. // 字典标签组件
  66. import DictTag from '@/components/DictTag'
  67. // 多语言
  68. import i18n from "@/lang/index";
  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.downloadFile = downloadFile
  78. app.config.globalProperties.parseTime = parseTime
  79. app.config.globalProperties.resetForm = resetForm
  80. app.config.globalProperties.handleTree = handleTree
  81. app.config.globalProperties.addDateRange = addDateRange
  82. app.config.globalProperties.selectDictLabel = selectDictLabel
  83. app.config.globalProperties.selectDictLabels = selectDictLabels
  84. app.config.globalProperties.t = i18n.global.t
  85. //字典回显
  86. app.config.globalProperties.dictDataEcho = dictDataEcho
  87. app.config.globalProperties.dictValueLabel = dictValueLabel
  88. app.config.globalProperties.moneyFormat = moneyFormat
  89. app.config.globalProperties.calculationWeek = calculationWeek
  90. app.config.globalProperties.getDict = getDict
  91. app.config.globalProperties.getDictOne = getDictOne
  92. app.config.globalProperties.getPdf = getPdf
  93. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
  94. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
  95. app.config.globalProperties.random = random
  96. app.config.globalProperties.deepClone = deepClone
  97. app.config.globalProperties.timeInterval = timeInterval
  98. app.config.globalProperties.compareTime = compareTime
  99. app.config.globalProperties.generateAuthorization = generateAuthorization
  100. // 全局组件挂载
  101. app.component('DictTag', DictTag)
  102. app.component('Pagination', Pagination)
  103. app.component('TreeSelect', TreeSelect)
  104. app.component('FileUpload', FileUpload)
  105. app.component('ImageUpload', ImageUpload)
  106. app.component('ImagePreview', ImagePreview)
  107. app.component('RightToolbar', RightToolbar)
  108. app.use(router)
  109. app.use(store)
  110. app.use(plugins)
  111. app.use(i18n)
  112. app.use(elementIcons)
  113. app.component('svg-icon', SvgIcon)
  114. directive(app)
  115. // 使用element-plus 并且设置全局的大小
  116. app.use(ElementPlus, {
  117. locale: locale,
  118. // 支持 large、default、small
  119. size: Cookies.get('size') || 'default'
  120. })
  121. app.mount('#app')