main.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 VxeTable from 'vxe-table'
  6. import 'vxe-table/lib/style.css'
  7. import VxeUI from 'vxe-pc-ui'
  8. import 'vxe-pc-ui/lib/style.css'
  9. import moment from 'moment'
  10. // import emitter from './eventBus';
  11. moment.locale('zh-cn')
  12. import './assets/font-awesome-4.7.0/css/font-awesome.min.css'
  13. import '@/assets/styles/index.scss' // global css
  14. import '@/assets/styles/ezhizao/list.css'
  15. import '@/assets/styles/ezhizao/form.css'
  16. import '@/assets/styles/ezhizao/dialog.css'
  17. import App from './App'
  18. import store from './store'
  19. import router from './router'
  20. import directive from './directive' // directive
  21. // import Notification from './views/dialog/notification.vue'
  22. // 注册指令
  23. import plugins from './plugins' // plugins
  24. import { download } from '@/utils/request'
  25. // svg图标
  26. import 'virtual:svg-icons-register'
  27. import SvgIcon from '@/components/SvgIcon'
  28. import elementIcons from '@/components/SvgIcon/svgicon'
  29. import './permission' // permission control
  30. import { useDict } from '@/utils/dict'
  31. import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'
  32. import { deepClone } from '@/utils/index'
  33. // 分页组件
  34. import Pagination from '@/components/Pagination'
  35. // 分页组件
  36. import PaginationMax from '@/components/PaginationMax'
  37. // 自定义表格工具组件
  38. import RightToolbar from '@/components/RightToolbar'
  39. // 文件上传组件
  40. import FileUpload from '@/components/FileUpload'
  41. // 图片上传组件
  42. import ImageUpload from '@/components/ImageUpload'
  43. // 图片预览组件
  44. import ImagePreview from '@/components/ImagePreview'
  45. // 自定义树选择组件
  46. import TreeSelect from '@/components/TreeSelect'
  47. // 字典标签组件
  48. import DictTag from '@/components/DictTag'
  49. // 富文本编辑器
  50. import Editor from './components/Editor'
  51. // vueCountTo
  52. import CountTo from './components/VueCountTo'
  53. // echart
  54. import * as echarts from 'echarts'
  55. const app = createApp(App)
  56. // 全局方法挂载
  57. app.config.globalProperties.useDict = useDict
  58. app.config.globalProperties.download = download
  59. app.config.globalProperties.parseTime = parseTime
  60. app.config.globalProperties.resetForm = resetForm
  61. app.config.globalProperties.handleTree = handleTree
  62. app.config.globalProperties.addDateRange = addDateRange
  63. app.config.globalProperties.selectDictLabel = selectDictLabel
  64. app.config.globalProperties.selectDictLabels = selectDictLabels
  65. app.config.globalProperties.deepClone = deepClone
  66. app.config.globalProperties.moment = moment
  67. app.config.globalProperties.echarts = echarts
  68. // 全局组件挂载
  69. app.component('DictTag', DictTag)
  70. app.component('Pagination', Pagination)
  71. app.component('PaginationMax', PaginationMax)
  72. app.component('TreeSelect', TreeSelect)
  73. app.component('FileUpload', FileUpload)
  74. app.component('ImageUpload', ImageUpload)
  75. app.component('ImagePreview', ImagePreview)
  76. app.component('RightToolbar', RightToolbar)
  77. app.component('Editor', Editor)
  78. app.component('CountTo', CountTo)
  79. // app.component('Notification', Notification)
  80. // app.config.globalProperties.$emitter = emitter;
  81. // app.config.globalProperties.$showDialog = function (message) {
  82. // emitter.emit('show-dialog', message);
  83. // };
  84. // const globalDialogInstance = app._context.components.Notification;
  85. // app.config.globalProperties.$showDialog = function (data) {
  86. // const instance = globalDialogInstance.setup();
  87. // console.log(data)
  88. // // instance.$el.innerHTML = data;
  89. // document.body.appendChild(instance.$el);
  90. // instance.open();
  91. // };
  92. // app.mixin({
  93. // onBeforeMount() {
  94. // globalVueInstance = this;
  95. // },
  96. // onUnmounted() {
  97. // globalVueInstance = null;
  98. // }
  99. // });
  100. app.use(router)
  101. app.use(store)
  102. app.use(plugins)
  103. app.use(elementIcons)
  104. app.use(VxeTable)
  105. app.use(VxeUI)
  106. app.component('svg-icon', SvgIcon)
  107. directive(app)
  108. // 使用element-plus 并且设置全局的大小
  109. app.use(ElementPlus, {
  110. locale: locale,
  111. // 支持 large、default、small
  112. size: Cookies.get('size') || 'default'
  113. })
  114. app.mount('#app')