main.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Vue from 'vue';
  2. import './public-path';
  3. import App from './App.vue';
  4. import store from './store';
  5. import router from './router';
  6. import permission from './utils/permission';
  7. import { MAP_KEY, LICENSE_CODE } from '@/config/setting';
  8. import EleAdmin from 'ele-admin';
  9. import VueClipboard from 'vue-clipboard2';
  10. import i18n from './i18n';
  11. import './styles/index.scss';
  12. import DictSelection from '@/components/Dict/DictSelection';
  13. import HeaderTitle from '@/components/header-title';
  14. import initParentStore from '../qiankun_config/store';
  15. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  16. import { create, all } from 'mathjs'; // 引入mathjs工具并初始化
  17. import authSelection from '@/components/authSelection';
  18. Vue.use(elTableInfiniteScroll);
  19. const config = {
  20. number: 'BigNumber',
  21. precision: 64
  22. };
  23. Vue.prototype.$math = create(all, config);
  24. Vue.component('HeaderTitle', HeaderTitle);
  25. Vue.component('authSelection', authSelection);
  26. // // register globally
  27. import '@/icons';
  28. Vue.component('DictSelection', DictSelection);
  29. Vue.config.productionTip = false;
  30. Vue.use(EleAdmin, {
  31. response: {
  32. dataName: 'list'
  33. },
  34. mapKey: MAP_KEY,
  35. license: LICENSE_CODE,
  36. i18n: (key, value) => i18n.t(key, value)
  37. });
  38. Vue.use(permission);
  39. Vue.use(VueClipboard);
  40. let instance = null;
  41. function render(props = {}) {
  42. const { container, routerBase } = props;
  43. // const router = new VueRouter({
  44. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  45. // mode: 'history',
  46. // routes
  47. // });
  48. instance = new Vue({
  49. router,
  50. store,
  51. i18n,
  52. render: (h) => h(App)
  53. }).$mount(container ? container.querySelector('#app') : '#app');
  54. }
  55. if (!window.__POWERED_BY_QIANKUN__) {
  56. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  57. render();
  58. }
  59. export async function bootstrap() {
  60. console.log('[vue] vue app bootstraped');
  61. }
  62. export async function mount(props) {
  63. console.log('[vue] props from main framework', props);
  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. }