main.js 4.8 KB

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