main.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. // bpmnProcessDesigner 需要引入
  17. import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
  18. Vue.use(MyPD);
  19. import '@/components/bpmnProcessDesigner/package/theme/index.scss';
  20. import 'bpmn-js/dist/assets/diagram-js.css';
  21. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
  22. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
  23. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
  24. import { create, all } from 'mathjs'; // 引入mathjs工具并初始化
  25. import authSelection from '@/components/AuthSelection';
  26. import Print from 'vue-printjs';
  27. Vue.use(Print);
  28. Vue.use(elTableInfiniteScroll);
  29. const config = {
  30. number: 'BigNumber',
  31. precision: 64
  32. };
  33. Vue.prototype.$math = create(all, config);
  34. Vue.component('HeaderTitle', HeaderTitle);
  35. Vue.component('authSelection', authSelection);
  36. // // register globally
  37. import '@/icons';
  38. Vue.component('DictSelection', DictSelection);
  39. Vue.config.productionTip = false;
  40. Vue.use(EleAdmin, {
  41. response: {
  42. dataName: 'list'
  43. },
  44. mapKey: MAP_KEY,
  45. license: LICENSE_CODE,
  46. i18n: (key, value) => i18n.t(key, value)
  47. });
  48. Vue.use(permission);
  49. Vue.use(VueClipboard);
  50. let instance = null;
  51. function render(props = {}) {
  52. const { container, routerBase } = props;
  53. // const router = new VueRouter({
  54. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  55. // mode: 'history',
  56. // routes
  57. // });
  58. instance = new Vue({
  59. router,
  60. store,
  61. i18n,
  62. render: (h) => h(App)
  63. }).$mount(container ? container.querySelector('#app') : '#app');
  64. }
  65. if (!window.__POWERED_BY_QIANKUN__) {
  66. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  67. render();
  68. }
  69. export async function bootstrap() {
  70. console.log('[vue] vue app bootstraped');
  71. }
  72. export async function mount(props) {
  73. console.log('[vue] props from main framework', props);
  74. initParentStore(props.store);
  75. props.onGlobalStateChange((state, prev) => {
  76. // state: 变更后的状态; prev 变更前的状态
  77. initParentStore(state);
  78. });
  79. render(props);
  80. }
  81. export async function unmount() {
  82. instance.$destroy();
  83. instance.$el.innerHTML = '';
  84. instance = null;
  85. }