main.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Vue from 'vue';
  2. import App from './App.vue';
  3. import store from './store';
  4. import router from './router';
  5. import permission from './utils/permission';
  6. import { MAP_KEY, LICENSE_CODE } from '@/config/setting';
  7. import EleAdmin from 'ele-admin';
  8. import i18n from './i18n';
  9. import './styles/index.scss';
  10. import DictSelection from '@/components/Dict/DictSelection';
  11. import { registerMicroApps, start, setDefaultMountApp } from 'qiankun';
  12. import microApps from './micro-app';
  13. // // register globally
  14. import '@/icons';
  15. Vue.component('DictSelection', DictSelection);
  16. Vue.config.productionTip = false;
  17. Vue.use(EleAdmin, {
  18. response: {
  19. dataName: 'list'
  20. },
  21. mapKey: MAP_KEY,
  22. license: LICENSE_CODE,
  23. i18n: (key, value) => i18n.t(key, value)
  24. });
  25. Vue.use(permission);
  26. // new Vue({
  27. // router,
  28. // store,
  29. // i18n,
  30. // render: (h) => h(App)
  31. // }).$mount('#app');
  32. const instance = new Vue({
  33. router,
  34. store,
  35. i18n,
  36. render: (h) => h(App)
  37. }).$mount('#app');
  38. console.log(instance.$store, ' mian-store', instance.$store.state);
  39. // 定义loader方法,loading改变时,将变量赋值给App.vue的data中的isLoading
  40. function loader (loading) {
  41. if (instance && instance.$children) {
  42. // instance.$children[0] 是App.vue,此时直接改动App.vue的isLoading
  43. instance.$children[0].isLoading = loading;
  44. }
  45. }
  46. // 给子应用配置加上loader方法
  47. const apps = microApps.map((item) => {
  48. return {
  49. ...item,
  50. loader
  51. };
  52. });
  53. registerMicroApps(apps, {
  54. beforeLoad: (app) => {
  55. console.log('before load app.name====>>>>>', app.name);
  56. },
  57. beforeMount: [
  58. (app) => {
  59. console.log('[LifeCycle] before mount %c%s', 'color: green;', app.name);
  60. }
  61. ],
  62. afterMount: [
  63. (app) => {
  64. console.log('[LifeCycle] after mount %c%s', 'color: green;', app.name);
  65. }
  66. ],
  67. afterUnmount: [
  68. (app) => {
  69. console.log('[LifeCycle] after unmount %c%s', 'color: green;', app.name);
  70. }
  71. ]
  72. });
  73. // setDefaultMountApp('/main-data');
  74. start();