main.js 2.2 KB

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