main.js 2.1 KB

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