main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { createApp } from 'vue'
  2. import Cookies from 'js-cookie'
  3. import ElementPlus from 'element-plus'
  4. import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
  5. import '@/assets/styles/index.scss' // global css
  6. import App from './App'
  7. import store from './store'
  8. import router from './router'
  9. import directive from './directive' // directive
  10. // 注册指令
  11. import plugins from './plugins' // plugins
  12. import { download } from '@/utils/request'
  13. // svg图标
  14. import 'virtual:svg-icons-register'
  15. import SvgIcon from '@/components/SvgIcon'
  16. import elementIcons from '@/components/SvgIcon/svgicon'
  17. import './permission' // permission control
  18. import { useDict } from '@/utils/dict'
  19. import { getConfigKey, updateConfigByKey } from "@/api/system/config";
  20. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
  21. // 分页组件
  22. import Pagination from '@/components/Pagination'
  23. // 自定义表格工具组件
  24. import RightToolbar from '@/components/RightToolbar'
  25. // 富文本组件
  26. import Editor from "@/components/Editor"
  27. // 文件上传组件
  28. import FileUpload from "@/components/FileUpload"
  29. // 图片上传组件
  30. import ImageUpload from "@/components/ImageUpload"
  31. // 图片预览组件
  32. import ImagePreview from "@/components/ImagePreview"
  33. // 自定义树选择组件
  34. import TreeSelect from '@/components/TreeSelect'
  35. // 字典标签组件
  36. import DictTag from '@/components/DictTag'
  37. // 条码
  38. import JsBarcode from 'jsbarcode'
  39. // 打印
  40. import print from 'vue3-print-nb'
  41. const app = createApp(App)
  42. // 全局方法挂载
  43. app.config.globalProperties.useDict = useDict
  44. app.config.globalProperties.getConfigKey = getConfigKey
  45. app.config.globalProperties.updateConfigByKey = updateConfigByKey
  46. app.config.globalProperties.download = download
  47. app.config.globalProperties.parseTime = parseTime
  48. app.config.globalProperties.resetForm = resetForm
  49. app.config.globalProperties.handleTree = handleTree
  50. app.config.globalProperties.addDateRange = addDateRange
  51. app.config.globalProperties.selectDictLabel = selectDictLabel
  52. app.config.globalProperties.selectDictLabels = selectDictLabels
  53. app.config.globalProperties.jsbarcode = JsBarcode
  54. // 全局组件挂载
  55. app.component('DictTag', DictTag)
  56. app.component('Pagination', Pagination)
  57. app.component('TreeSelect', TreeSelect)
  58. app.component('FileUpload', FileUpload)
  59. app.component('ImageUpload', ImageUpload)
  60. app.component('ImagePreview', ImagePreview)
  61. app.component('RightToolbar', RightToolbar)
  62. app.component('Editor', Editor)
  63. app.use(router)
  64. app.use(store)
  65. app.use(plugins)
  66. app.use(elementIcons)
  67. app.use(print)
  68. app.component('svg-icon', SvgIcon)
  69. directive(app)
  70. // 使用element-plus 并且设置全局的大小
  71. app.use(ElementPlus, {
  72. locale: locale,
  73. // 支持 large、default、small
  74. size: Cookies.get('size') || 'default'
  75. })
  76. // 修改 el-dialog 默认点击遮照为不关闭
  77. app._context.components.ElDialog.props.closeOnClickModal.default = false
  78. app.mount('#app')