main.js 5.2 KB

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