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