main.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import Vue from 'vue';
  2. import 'normalize.css/normalize.css'; // A modern alternative to CSS resets
  3. import ElementUI from 'element-ui';
  4. import 'element-ui/lib/theme-chalk/index.css';
  5. import locale from 'element-ui/lib/locale/lang/en'; // lang i18n
  6. import '@/styles/index.scss'; // global css
  7. import App from './App';
  8. import store from './store';
  9. import router from './router';
  10. import '@/icons'; // icon
  11. import '@/permission'; // permission control
  12. import './components';
  13. import './containers';
  14. import 'utils/dialog-helper';
  15. import '@/plugins/viewerjs';
  16. import message from '@/utils/message';
  17. import bus from './utils/bus';
  18. Vue.prototype.$Bus = bus;
  19. Vue.prototype.$g_emit = (eventName, payload) => {
  20. bus.$emit(eventName, payload);
  21. };
  22. Vue.prototype.$g_on = (eventName, func) => {
  23. bus.$on(eventName, func);
  24. };
  25. Vue.prototype.$g_off = (eventName, func) => {
  26. bus.$off(eventName, func);
  27. };
  28. /**
  29. * If you don't want to use mock-server
  30. * you want to use MockJs for mock api
  31. * you can execute: mockXHR()
  32. *
  33. * Currently MockJs will be used in the production environment,
  34. * please remove it before going online ! ! !
  35. */
  36. if (process.env.NODE_ENV === 'production') {
  37. const { mockXHR } = require('../mock');
  38. mockXHR();
  39. }
  40. // set ElementUI lang to EN
  41. // Vue.use(ElementUI, { locale })
  42. // 如果想要中文版 element-ui,按如下方式声明
  43. Vue.use(ElementUI, { size: 'small', zIndex: 3000 });
  44. Vue.config.productionTip = false;
  45. // 提示
  46. Vue.prototype.$success = message.success;
  47. Vue.prototype.$error = message.error;
  48. Vue.prototype.$warning = message.warning;
  49. new Vue({
  50. el: '#app',
  51. router,
  52. store,
  53. render: h => h(App)
  54. });