main.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import Vue from 'vue';
  2. import Cookies from 'store';
  3. import { startsWith } from 'lodash-es';
  4. import Element from 'element-ui';
  5. import './assets/styles/element-variables.scss';
  6. import 'fontawesome-free-6.2.1/css/all.min.css';
  7. import '@/assets/styles/index.scss'; // global css
  8. import '@/assets/styles/global.scss'; // global css
  9. import '@/assets/styles/ruoyi.scss'; // ruoyi css
  10. import App from './App';
  11. import store from './store';
  12. import router from './router';
  13. import directive from './directive'; // directive
  14. import './filters';
  15. import plugins from './plugins'; // plugins
  16. import { download } from '@/utils/request';
  17. import './assets/icons'; // icon
  18. import './permission'; // permission control
  19. import { getDataByDatatypeCode } from '@/api/system/dict/data';
  20. import { getConfigKey } from '@/api/system/config';
  21. import {
  22. parseTime,
  23. resetForm,
  24. addDateRange,
  25. selectDictLabel,
  26. selectDictLabels,
  27. handleTree
  28. } from '@/utils/ruoyi';
  29. // 分页组件
  30. import Pagination from '@/components/Pagination';
  31. // 自定义表格工具组件
  32. import RightToolbar from '@/components/RightToolbar';
  33. // 富文本组件
  34. import Editor from '@/components/Editor';
  35. // 文件上传组件
  36. import FileUpload from '@/components/FileUpload';
  37. // 图片上传组件
  38. import ImageUpload from '@/components/ImageUpload';
  39. // 图片预览组件
  40. import ImagePreview from '@/components/ImagePreview';
  41. // 字典标签组件
  42. import DictTag from '@/components/DictTag';
  43. // 头部标签组件
  44. import VueMeta from 'vue-meta';
  45. // 字典数据组件
  46. import DictData from '@/components/DictData';
  47. import VueAMap from 'vue-amap';
  48. function formatImg(url) {
  49. const prefix = process.env.VUE_APP_BASE_API;
  50. if (!url) {
  51. return '-';
  52. }
  53. return startsWith(url, 'http') ? url : prefix + url;
  54. }
  55. Vue.filter('formatImg', formatImg);
  56. // 全局方法挂载
  57. Vue.prototype.getDataByDatatypeCode = getDataByDatatypeCode;
  58. Vue.prototype.getConfigKey = getConfigKey;
  59. Vue.prototype.parseTime = parseTime;
  60. Vue.prototype.resetForm = resetForm;
  61. Vue.prototype.addDateRange = addDateRange;
  62. Vue.prototype.selectDictLabel = selectDictLabel;
  63. Vue.prototype.selectDictLabels = selectDictLabels;
  64. Vue.prototype.download = download;
  65. Vue.prototype.handleTree = handleTree;
  66. // 全局组件挂载
  67. Vue.component('DictTag', DictTag);
  68. Vue.component('Pagination', Pagination);
  69. Vue.component('RightToolbar', RightToolbar);
  70. Vue.component('Editor', Editor);
  71. Vue.component('FileUpload', FileUpload);
  72. Vue.component('ImageUpload', ImageUpload);
  73. Vue.component('ImagePreview', ImagePreview);
  74. Vue.use(VueAMap);
  75. // 初始化vue-amap
  76. VueAMap.initAMapApiLoader({
  77. // 高德的key
  78. key: 'bd1582190896ab05afb30aa8161d14c2',
  79. // 插件集合
  80. plugin: [
  81. 'Autocomplete',
  82. 'AMap.PlaceSearch',
  83. 'AMap.Scale',
  84. 'AMap.OverView',
  85. 'AMap.ToolBar',
  86. 'AMap.MapType',
  87. 'AMap.PolyEditor',
  88. 'AMap.PolygonEditor',
  89. 'AMap.CircleEditor',
  90. 'AMap.Geocoder',
  91. 'AMap.ElasticMarker'
  92. ],
  93. // 高德 sdk 版本,默认为 1.4.4
  94. v: '2.0'
  95. });
  96. Vue.use(directive);
  97. Vue.use(plugins);
  98. Vue.use(VueMeta);
  99. DictData.install();
  100. /**
  101. * If you don't want to use mock-server
  102. * you want to use MockJs for mock api
  103. * you can execute: mockXHR()
  104. *
  105. * Currently MockJs will be used in the production environment,
  106. * please remove it before going online! ! !
  107. */
  108. Vue.use(Element, {
  109. size: Cookies.get('size') || 'medium' // set element-ui default size
  110. });
  111. Vue.config.productionTip = false;
  112. new Vue({
  113. el: '#app',
  114. router,
  115. store,
  116. render: (h) => h(App)
  117. });