main.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. let prefix =
  15. window.location.protocol.indexOf("https") >= 0 ? "https://" : "http://";
  16. const uploadUrl =
  17. prefix +
  18. import.meta.env.VITE_APP_UPLOAD_API +
  19. import.meta.env.VITE_APP_UPLOAD_BASE_API + '/open/fileInfo/upload'
  20. // 注册指令
  21. import plugins from './plugins' // plugins
  22. import {
  23. download,
  24. post,
  25. postTwo,
  26. get
  27. } from '@/utils/request'
  28. // svg图标
  29. import 'virtual:svg-icons-register'
  30. import SvgIcon from '@/components/SvgIcon'
  31. import elementIcons from '@/components/SvgIcon/svgicon'
  32. import './permission' // permission control
  33. import {
  34. useDict
  35. } from '@/utils/dict'
  36. import {
  37. parseTime,
  38. resetForm,
  39. addDateRange,
  40. handleTree,
  41. selectDictLabel,
  42. selectDictLabels
  43. } from '@/utils/ruoyi'
  44. import {
  45. dictDataEcho,
  46. dictValueLabel,
  47. dictKeyValue,
  48. moneyFormat,
  49. calculationWeek,
  50. getDict,
  51. getDictOne,
  52. getPdf,
  53. getPdfTransverseA4,
  54. translateIntoEnglish,
  55. random,
  56. deepClone,
  57. timeInterval,
  58. compareTime,
  59. getImgBase64,
  60. getFileData,
  61. msgTip,
  62. msgConfirm
  63. } from '@/utils/util'
  64. // userStore
  65. import useUserStore from "@/store/modules/user";
  66. // 分页组件
  67. import Pagination from '@/components/Pagination'
  68. // 自定义表格工具组件
  69. import RightToolbar from '@/components/RightToolbar'
  70. // 图片上传组件
  71. import ImageUpload from "@/components/ImageUpload"
  72. // 图片预览组件
  73. import ImagePreview from "@/components/ImagePreview"
  74. // 自定义树选择组件
  75. import TreeSelect from '@/components/TreeSelect'
  76. // 字典标签组件
  77. import DictTag from '@/components/DictTag'
  78. // 多语言
  79. import i18n from "@/lang/index";
  80. // 打印
  81. import print from "vue3-print-nb"
  82. // import * as echarts from "echarts";
  83. // import 'echarts-gl'
  84. // import './world.js'
  85. const app = createApp(App)
  86. console.log(i18n.global.t('login.welcomeToLogin'))
  87. // 全局方法挂载
  88. app.config.globalProperties.uploadUrl = uploadUrl
  89. app.config.globalProperties.useDict = useDict
  90. app.config.globalProperties.get = get
  91. app.config.globalProperties.post = post
  92. app.config.globalProperties.postTwo = postTwo
  93. app.config.globalProperties.download = download
  94. app.config.globalProperties.msgTip = msgTip
  95. app.config.globalProperties.msgConfirm = msgConfirm
  96. app.config.globalProperties.parseTime = parseTime
  97. app.config.globalProperties.resetForm = resetForm
  98. app.config.globalProperties.handleTree = handleTree
  99. app.config.globalProperties.addDateRange = addDateRange
  100. app.config.globalProperties.selectDictLabel = selectDictLabel
  101. app.config.globalProperties.selectDictLabels = selectDictLabels
  102. app.config.globalProperties.t = i18n.global.t
  103. app.config.globalProperties.getFileData = getFileData
  104. //字典回显
  105. app.config.globalProperties.dictKeyValue = dictKeyValue
  106. app.config.globalProperties.dictDataEcho = dictDataEcho
  107. app.config.globalProperties.dictValueLabel = dictValueLabel
  108. app.config.globalProperties.moneyFormat = moneyFormat
  109. app.config.globalProperties.calculationWeek = calculationWeek
  110. app.config.globalProperties.getDict = getDict
  111. app.config.globalProperties.getDictOne = getDictOne
  112. app.config.globalProperties.getPdf = getPdf
  113. app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
  114. app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
  115. app.config.globalProperties.random = random
  116. app.config.globalProperties.deepClone = deepClone
  117. app.config.globalProperties.timeInterval = timeInterval
  118. app.config.globalProperties.compareTime = compareTime
  119. app.config.globalProperties.getImgBase64 = getImgBase64
  120. // user
  121. app.config.globalProperties.useUserStore = useUserStore
  122. // 全局组件挂载
  123. app.component('DictTag', DictTag)
  124. app.component('Pagination', Pagination)
  125. app.component('TreeSelect', TreeSelect)
  126. app.component('ImageUpload', ImageUpload)
  127. app.component('ImagePreview', ImagePreview)
  128. app.component('RightToolbar', RightToolbar)
  129. app.use(router)
  130. app.use(store)
  131. app.use(plugins)
  132. app.use(i18n)
  133. app.use(elementIcons)
  134. app.use(print)
  135. app.component('svg-icon', SvgIcon)
  136. directive(app)
  137. // 使用element-plus 并且设置全局的大小
  138. app.use(ElementPlus, {
  139. locale: locale,
  140. // 支持 large、default、small
  141. size: Cookies.get('size') || 'default'
  142. })
  143. app.mount('#app')