main.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. import DICT from '@/const/dictType';
  19. import TABLECOLSIZE from '@/const/tableColSize';
  20. // 时间
  21. import Moment from 'moment';
  22. Vue.prototype.$Bus = bus;
  23. Vue.prototype.$g_emit = (eventName, payload) => {
  24. bus.$emit(eventName, payload);
  25. };
  26. Vue.prototype.$g_on = (eventName, func) => {
  27. bus.$on(eventName, func);
  28. };
  29. Vue.prototype.$g_off = (eventName, func) => {
  30. bus.$off(eventName, func);
  31. };
  32. /**
  33. * If you don't want to use mock-server
  34. * you want to use MockJs for mock api
  35. * you can execute: mockXHR()
  36. *
  37. * Currently MockJs will be used in the production environment,
  38. * please remove it before going online ! ! !
  39. */
  40. if (process.env.NODE_ENV === 'production') {
  41. const { mockXHR } = require('../mock');
  42. mockXHR();
  43. }
  44. // set ElementUI lang to EN
  45. // Vue.use(ElementUI, { locale })
  46. // 如果想要中文版 element-ui,按如下方式声明
  47. Vue.use(ElementUI, { size: 'small', zIndex: 3000 });
  48. Vue.config.productionTip = false;
  49. // 提示
  50. Vue.prototype.$success = message.success;
  51. Vue.prototype.$error = message.error;
  52. Vue.prototype.$warning = message.warning;
  53. Vue.prototype.$moment = Moment;
  54. // 数据字典搜索关键词
  55. Vue.prototype.$dict = DICT;
  56. // 表格单列宽度
  57. Vue.prototype.$col = TABLECOLSIZE;
  58. Vue.prototype.$upload = url => `${process.env.VUE_APP_BASE_API}${url}`;
  59. window.UEDITOR_CONFIG = `${process.env.VUE_APP_BASE_API}/yxl-back-end/framework/oss/ueditor/ueditor-action`;
  60. window.UEDITOR_SERVER_URL = `${process.env.VUE_APP_BASE_API}/yxl-back-end/framework/oss/ueditor/ueditor-action`;
  61. // window.UEDITOR_CONFIG = `https://ex.by-health.com/baby-institute-back-end/oss/ueditor/ueditor-action`;
  62. // window.UEDITOR_SERVER_URL = `https://ex.by-health.com/baby-institute-back-end/oss/ueditor/ueditor-action`;
  63. Vue.prototype.$filterRichTxt = str => {
  64. if (!str) return '';
  65. return str.replace(/<img/g, '<img width="100%"');
  66. };
  67. new Vue({
  68. el: '#app',
  69. router,
  70. store,
  71. render: h => h(App)
  72. });