main.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. const app = createApp(App)
  38. // 全局方法挂载
  39. app.config.globalProperties.useDict = useDict
  40. app.config.globalProperties.getConfigKey = getConfigKey
  41. app.config.globalProperties.updateConfigByKey = updateConfigByKey
  42. app.config.globalProperties.download = download
  43. app.config.globalProperties.parseTime = parseTime
  44. app.config.globalProperties.resetForm = resetForm
  45. app.config.globalProperties.handleTree = handleTree
  46. app.config.globalProperties.addDateRange = addDateRange
  47. app.config.globalProperties.selectDictLabel = selectDictLabel
  48. app.config.globalProperties.selectDictLabels = selectDictLabels
  49. // 全局组件挂载
  50. app.component('DictTag', DictTag)
  51. app.component('Pagination', Pagination)
  52. app.component('TreeSelect', TreeSelect)
  53. app.component('FileUpload', FileUpload)
  54. app.component('ImageUpload', ImageUpload)
  55. app.component('ImagePreview', ImagePreview)
  56. app.component('RightToolbar', RightToolbar)
  57. app.component('Editor', Editor)
  58. app.use(router)
  59. app.use(store)
  60. app.use(plugins)
  61. app.use(elementIcons)
  62. app.component('svg-icon', SvgIcon)
  63. directive(app)
  64. // 使用element-plus 并且设置全局的大小
  65. app.use(ElementPlus, {
  66. locale: locale,
  67. // 支持 large、default、small
  68. size: Cookies.get('size') || 'default'
  69. })
  70. // 修改 el-dialog 默认点击遮照为不关闭
  71. app._context.components.ElDialog.props.closeOnClickModal.default = false
  72. app.mount('#app')