main.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Vue from 'vue';
  2. import './public-path';
  3. import initParentStore from '../qiankun_config/store';
  4. import App from './App.vue';
  5. import store from './store';
  6. import router from './router';
  7. import permission from './utils/permission';
  8. import { MAP_KEY, LICENSE_CODE } from '@/config/setting';
  9. import EleAdmin from 'ele-admin';
  10. import VueClipboard from 'vue-clipboard2';
  11. import i18n from './i18n';
  12. import './styles/index.scss';
  13. import 'echarts-gl';
  14. import DictSelection from '@/components/Dict/DictSelection';
  15. import HeaderTitle from '@/components/header-title';
  16. import dataV from '@jiaminghi/data-view';
  17. Vue.component('HeaderTitle', HeaderTitle);
  18. // // register globally
  19. import '@/icons';
  20. Vue.component('DictSelection', DictSelection);
  21. Vue.config.productionTip = false;
  22. Vue.use(EleAdmin, {
  23. response: {
  24. dataName: 'list'
  25. },
  26. mapKey: MAP_KEY,
  27. license: LICENSE_CODE,
  28. i18n: (key, value) => i18n.t(key, value)
  29. });
  30. Vue.use(permission);
  31. Vue.use(VueClipboard);
  32. Vue.use(dataV);
  33. let instance = null;
  34. function render(props = {}) {
  35. const { container, routerBase } = props;
  36. // const router = new VueRouter({
  37. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  38. // mode: 'history',
  39. // routes
  40. // });
  41. instance = new Vue({
  42. router,
  43. store,
  44. i18n,
  45. render: (h) => h(App)
  46. }).$mount(container ? container.querySelector('#app') : '#app');
  47. }
  48. if (!window.__POWERED_BY_QIANKUN__) {
  49. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  50. render();
  51. }
  52. export async function bootstrap() {
  53. console.log('[vue] vue app bootstraped');
  54. }
  55. export async function mount(props) {
  56. console.log('[vue] props from main framework', props);
  57. Vue.prototype.$portalStore = props.store;
  58. initParentStore(props.store);
  59. props.onGlobalStateChange((state, prev) => {
  60. // state: 变更后的状态; prev 变更前的状态
  61. initParentStore(state);
  62. });
  63. render(props);
  64. }
  65. export async function unmount() {
  66. instance.$destroy();
  67. instance.$el.innerHTML = '';
  68. instance = null;
  69. }