main.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. // element css
  7. import 'element-plus/es/components/message/style/css';
  8. import 'element-plus/es/components/message-box/style/css';
  9. import 'element-plus/es/components/notification/style/css';
  10. import 'element-plus/es/components/loading/style/css';
  11. // tailwindcss
  12. import './index.css';
  13. import App from './App.vue';
  14. import store from './store';
  15. import router from './router';
  16. import directive from './directive'; // directive
  17. // 注册指令
  18. import plugins from './plugins'; // plugins
  19. import { download } from '@/utils/request';
  20. // svg图标
  21. import 'virtual:svg-icons-register';
  22. import SvgIcon from '@/components/SvgIcon/index.vue';
  23. import elementIcons from '@/components/SvgIcon/svgicon';
  24. import './permission'; // permission control
  25. import { useDict } from '@/utils/dict';
  26. import {
  27. parseTime,
  28. resetForm,
  29. addDateRange,
  30. handleTree,
  31. selectDictLabel,
  32. selectDictLabels,
  33. } from '@/utils/ruoyi';
  34. // 分页组件
  35. import Pagination from '@/components/Pagination/index.vue';
  36. // 自定义表格工具组件
  37. import RightToolbar from '@/components/RightToolbar/index.vue';
  38. // 富文本组件
  39. import Editor from "@/components/Editor/index.vue"
  40. // 文件上传组件
  41. import FileUpload from '@/components/FileUpload/index.vue';
  42. // 图片上传组件
  43. import ImageUpload from '@/components/ImageUpload/index.vue';
  44. // 图片预览组件
  45. import ImagePreview from '@/components/ImagePreview/index.vue';
  46. // 自定义树选择组件
  47. import TreeSelect from '@/components/TreeSelect/index.vue';
  48. // 字典标签组件
  49. import DictTag from '@/components/DictTag/index.vue';
  50. const app = createApp(App);
  51. // 全局方法挂载
  52. app.config.globalProperties.useDict = useDict;
  53. app.config.globalProperties.download = download;
  54. app.config.globalProperties.parseTime = parseTime;
  55. app.config.globalProperties.resetForm = resetForm;
  56. app.config.globalProperties.handleTree = handleTree;
  57. app.config.globalProperties.addDateRange = addDateRange;
  58. app.config.globalProperties.selectDictLabel = selectDictLabel;
  59. app.config.globalProperties.selectDictLabels = selectDictLabels;
  60. // 全局组件挂载
  61. app.component('DictTag', DictTag);
  62. app.component('Pagination', Pagination);
  63. app.component('TreeSelect', TreeSelect);
  64. app.component('FileUpload', FileUpload);
  65. app.component('ImageUpload', ImageUpload);
  66. app.component('ImagePreview', ImagePreview);
  67. app.component('RightToolbar', RightToolbar);
  68. app.component('Editor', Editor)
  69. app.use(router);
  70. app.use(store);
  71. app.use(plugins);
  72. app.use(elementIcons);
  73. app.component('svg-icon', SvgIcon);
  74. directive(app);
  75. // 使用element-plus 并且设置全局的大小
  76. app.use(ElementPlus, {
  77. locale: locale,
  78. // 支持 large、default、small
  79. size: Cookies.get('size') || 'default',
  80. });
  81. app.mount('#app');