main.js 2.9 KB

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