Newer
Older
KaiFengPC / src / main.js
@zhangdeliang zhangdeliang on 23 Jun 3 KB update
  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 'animate.css'; //引入animate
  9.  
  10. import App from './App';
  11. import moment from 'moment';
  12. import store from './store';
  13. import router from './router';
  14. import directive from './directive'; // directive
  15. import * as echarts from 'echarts';
  16. import 'echarts-gl';
  17.  
  18. // 注册指令
  19. import plugins from './plugins'; // plugins
  20. import { download } from '@/utils/request';
  21.  
  22. // svg图标
  23. import 'virtual:svg-icons-register';
  24. import SvgIcon from '@/components/SvgIcon';
  25. import elementIcons from '@/components/SvgIcon/svgicon';
  26. // 固定字典数据
  27. import { fixDict } from '@/utils/fixDict';
  28.  
  29. //权限控制
  30. import './permission'; // permission control
  31.  
  32. import { useDict } from '@/utils/dict';
  33.  
  34. import 'amfe-flexible'; // rem 布局适配
  35.  
  36. import {
  37. parseTime,
  38. resetForm,
  39. addDateRange,
  40. formatAddDateRange,
  41. handleTree,
  42. selectDictLabel,
  43. selectDictLabels,
  44. getImageUrl,
  45. getWeatherImageUrl,
  46. } from '@/utils/ruoyi';
  47.  
  48. // 表格组件
  49. import NewTable from '@/components/Table';
  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. import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传
  63.  
  64. const app = createApp(App);
  65.  
  66. // 全局方法挂载
  67. app.config.globalProperties.useDict = useDict;
  68. app.config.globalProperties.download = download;
  69. app.config.globalProperties.parseTime = parseTime;
  70. app.config.globalProperties.getImageUrl = getImageUrl;
  71. app.config.globalProperties.getWeatherImageUrl = getWeatherImageUrl;
  72. app.config.globalProperties.resetForm = resetForm;
  73. app.config.globalProperties.handleTree = handleTree;
  74. app.config.globalProperties.addDateRange = addDateRange;
  75. app.config.globalProperties.formatAddDateRange = formatAddDateRange;
  76. app.config.globalProperties.selectDictLabel = selectDictLabel;
  77. app.config.globalProperties.selectDictLabels = selectDictLabels;
  78. app.config.globalProperties.fixDict = fixDict;
  79. app.config.globalProperties.echarts = echarts;
  80. app.config.globalProperties.moment = moment;
  81. app.config.warnHandler = (msg, instance, trace) => {};
  82. //全局变量定义
  83. app.config.globalProperties.refresh = 1;
  84. // 全局组件挂载
  85. app.component('NewTable', NewTable);
  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('ImageFileUpload', ImageFileUpload);
  93.  
  94. app.use(router);
  95. app.use(store);
  96. app.use(plugins);
  97. app.use(elementIcons);
  98.  
  99. app.component('svg-icon', SvgIcon); //全局注册
  100.  
  101. // 错误打印
  102. app.config.errorHandler = (err, instance, info) => {
  103. // 处理错误,例如:报告给一个服务
  104. console.log('全局异常--', err, instance, info);
  105. };
  106.  
  107. directive(app);
  108.  
  109. // 使用element-plus 并且设置全局的大小
  110. app.use(ElementPlus, {
  111. locale: locale,
  112. // 支持 large、default、small
  113. size: Cookies.get('size') || 'default',
  114. });
  115.  
  116. app.mount('#app');