Newer
Older
DH_Apicture / src / main.js
@zhangqy zhangqy on 29 Nov 3 KB first commit
  1. import { createApp } from 'vue';
  2. import Cookies from 'js-cookie';
  3.  
  4. import ElementPlus from 'element-plus';
  5. import locale from 'element-plus/lib/locale/lang/zh-cn'; // 中文语言
  6. import 'dayjs/locale/zh-cn'; //实现Element plus设置日历每周第一天从周一开始
  7. import '@/assets/styles/index.scss'; // global css
  8. import vue3SeamlessScroll from 'vue3-seamless-scroll';
  9. import 'animate.css'; //引入animate
  10.  
  11. import App from './App';
  12. import moment from 'moment';
  13. import store from './store';
  14. import router from './router';
  15. import directive from './directive'; // directive
  16. import * as echarts from 'echarts';
  17. // 日历天气组件
  18. import DateSelect from '@/components/DateSelect';
  19.  
  20. // 注册指令
  21. import plugins from './plugins'; // plugins
  22. import { download } from '@/utils/request';
  23.  
  24. // svg图标
  25. import 'virtual:svg-icons-register';
  26. import SvgIcon from '@/components/SvgIcon';
  27. import elementIcons from '@/components/SvgIcon/svgicon';
  28. // 固定字典数据
  29. import { fixDict } from '@/utils/fixDict';
  30.  
  31. //权限控制
  32. import './permission'; // permission control
  33.  
  34. import { useDict } from '@/utils/dict';
  35.  
  36. import 'amfe-flexible'; // rem 布局适配
  37.  
  38. import {
  39. parseTime,
  40. resetForm,
  41. addDateRange,
  42. formatAddDateRange,
  43. handleTree,
  44. selectDictLabel,
  45. selectDictLabels,
  46. getImageUrl,
  47. selectArrListLabel
  48. } from '@/utils/ruoyi';
  49.  
  50. // 分页组件
  51. import Pagination from '@/components/Pagination';
  52. // 自定义表格工具组件
  53. import RightToolbar from '@/components/RightToolbar';
  54. // 图片预览组件
  55. import ImagePreview from '@/components/ImagePreview';
  56. // 自定义树选择组件
  57. import TreeSelect from '@/components/TreeSelect';
  58. // 字典标签组件
  59. import DictTag from '@/components/DictTag';
  60. //空数据组件
  61. import Empty from '@/components/Empty';
  62.  
  63. const app = createApp(App);
  64.  
  65. // 全局方法挂载
  66. app.config.globalProperties.useDict = useDict;
  67. app.config.globalProperties.download = download;
  68. app.config.globalProperties.parseTime = parseTime;
  69. app.config.globalProperties.getImageUrl = getImageUrl;
  70. app.config.globalProperties.resetForm = resetForm;
  71. app.config.globalProperties.handleTree = handleTree;
  72. app.config.globalProperties.addDateRange = addDateRange;
  73. app.config.globalProperties.formatAddDateRange = formatAddDateRange;
  74. app.config.globalProperties.selectDictLabel = selectDictLabel;
  75. app.config.globalProperties.selectDictLabels = selectDictLabels;
  76. app.config.globalProperties.selectArrListLabel = selectArrListLabel;
  77.  
  78. app.config.globalProperties.fixDict = fixDict;
  79. app.config.globalProperties.echarts = echarts;
  80. app.config.globalProperties.moment = moment;
  81.  
  82. //全局变量定义
  83. app.config.globalProperties.refresh = 1;
  84.  
  85. // 全局组件挂载
  86. app.component('DictTag', DictTag);
  87. app.component('Pagination', Pagination);
  88. app.component('TreeSelect', TreeSelect);
  89. app.component('ImagePreview', ImagePreview);
  90. app.component('RightToolbar', RightToolbar);
  91. app.component('Empty', Empty);
  92. app.component('DateSelect', DateSelect);
  93.  
  94. app.use(router);
  95. app.use(store);
  96. app.use(plugins);
  97. app.use(elementIcons);
  98. app.use(vue3SeamlessScroll);
  99.  
  100. app.component('svg-icon', SvgIcon); //全局注册
  101.  
  102. // 错误打印
  103. app.config.errorHandler = (err, instance, info) => {
  104. // 处理错误,例如:报告给一个服务
  105. console.log('全局异常--', err, instance, info);
  106. };
  107.  
  108. directive(app);
  109.  
  110. // 使用element-plus 并且设置全局的大小
  111. app.use(ElementPlus, {
  112. locale: locale,
  113. // 支持 large、default、small
  114. size: Cookies.get('size') || 'default',
  115. });
  116.  
  117. app.mount('#app');