main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 { LICENSE_CODE, MAP_KEY } 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 '@/components/FormGenerator/styles/index.scss';
  14. import DictSelection from '@/components/Dict/DictSelection';
  15. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  16. import lodash from 'lodash';
  17. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  18. // import tinymce from '@/components/FormGenerator/components/tinymce/index.js';
  19. // import TinymceEditor from '@/components/TinymceEditor/index.vue';
  20. // import SvgIcon from '@/components/FormGenerator/components/SvgIcon'; // svg component
  21. import HeaderTitle from '@/components/header-title';
  22. import { all, create } from 'mathjs'; // 引入mathjs工具并初始化
  23. // // register globally
  24. // Vue.component('tinymce', TinymceEditor);
  25. import '@/icons';
  26. // bpmnProcessDesigner 需要引入
  27. import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
  28. import '@/components/bpmnProcessDesigner/package/theme/index.scss';
  29. import 'bpmn-js/dist/assets/diagram-js.css';
  30. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
  31. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
  32. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
  33. import FormMaking from '../lib/vue-form-making/src/index';
  34. import '@/assets/font_icon/iconfont.css';
  35. Vue.use(elTableInfiniteScroll);
  36. Vue.component('HeaderTitle', HeaderTitle);
  37. Vue.component('processSubmitDialog', processSubmitDialog);
  38. const config = {
  39. number: 'BigNumber',
  40. precision: 64
  41. };
  42. Vue.prototype.$math = create(all, config);
  43. Vue.use(MyPD);
  44. Vue.use(FormMaking, {
  45. lang: 'zh-CN',
  46. i18n: i18n
  47. });
  48. Vue.component('DictSelection', DictSelection);
  49. Vue.config.productionTip = false;
  50. Vue.prototype._ = lodash;
  51. // 表单重置
  52. Vue.prototype.resetForm = function resetForm(refName) {
  53. if (this.$refs[refName]) {
  54. this.$refs[refName].resetFields();
  55. }
  56. };
  57. Vue.use(EleAdmin, {
  58. response: {
  59. dataName: 'list'
  60. },
  61. mapKey: MAP_KEY,
  62. license: LICENSE_CODE,
  63. i18n: (key, value) => i18n.t(key, value)
  64. });
  65. Vue.use(permission);
  66. Vue.use(VueClipboard);
  67. // new Vue({
  68. // router,
  69. // store,
  70. // i18n,
  71. // render: (h) => h(App)
  72. // }).$mount('#app');
  73. let instance = null;
  74. function render(props = {}) {
  75. console.log(router, 2222);
  76. const { container, routerBase } = props;
  77. // const router = new VueRouter({
  78. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  79. // mode: 'history',
  80. // routes
  81. // });
  82. instance = new Vue({
  83. router,
  84. store,
  85. i18n,
  86. render: (h) => h(App)
  87. }).$mount(container ? container.querySelector('#app') : '#app');
  88. }
  89. if (!window.__POWERED_BY_QIANKUN__) {
  90. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  91. render();
  92. }
  93. export async function bootstrap() {
  94. console.log('[vue] vue app bootstraped');
  95. }
  96. export async function mount(props) {
  97. console.log('[vue] props from main framework', props);
  98. Vue.prototype.$portalStore = props.store;
  99. initParentStore(props.store);
  100. // initParentStore(props.store?.state);
  101. props.onGlobalStateChange((state, prev) => {
  102. // state: 变更后的状态; prev 变更前的状态
  103. initParentStore(state);
  104. });
  105. render(props);
  106. }
  107. export async function unmount() {
  108. instance.$destroy();
  109. instance.$el.innerHTML = '';
  110. instance = null;
  111. }