main.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. import fileMain from '@/components/addDoc/index.vue';
  36. import './directives';
  37. import seekPage from '@/BIZComponents/seekPage';
  38. Vue.component('seekPage', seekPage);
  39. import Tooltip from './utils/tooltip'; // 引入封装的工具
  40. Vue.prototype.$tooltip = Tooltip;
  41. Vue.use(elTableInfiniteScroll);
  42. Vue.component('HeaderTitle', HeaderTitle);
  43. Vue.component('fileMain', fileMain);
  44. Vue.component('processSubmitDialog', processSubmitDialog);
  45. const config = {
  46. number: 'BigNumber',
  47. precision: 64
  48. };
  49. Vue.prototype.$math = create(all, config);
  50. Vue.use(MyPD);
  51. Vue.use(FormMaking, {
  52. lang: 'zh-CN',
  53. i18n: i18n
  54. });
  55. Vue.component('DictSelection', DictSelection);
  56. Vue.config.productionTip = false;
  57. Vue.prototype._ = lodash;
  58. // 表单重置
  59. Vue.prototype.resetForm = function resetForm(refName) {
  60. if (this.$refs[refName]) {
  61. this.$refs[refName].resetFields();
  62. }
  63. };
  64. Vue.use(EleAdmin, {
  65. response: {
  66. dataName: 'list'
  67. },
  68. mapKey: MAP_KEY,
  69. license: LICENSE_CODE,
  70. i18n: (key, value) => i18n.t(key, value)
  71. });
  72. Vue.use(permission);
  73. Vue.use(VueClipboard);
  74. // new Vue({
  75. // router,
  76. // store,
  77. // i18n,
  78. // render: (h) => h(App)
  79. // }).$mount('#app');
  80. let instance = null;
  81. function render(props = {}) {
  82. const { container, routerBase } = props;
  83. // Vue.component('fileMain', fileMain);
  84. // const router = new VueRouter({
  85. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  86. // mode: 'history',
  87. // routes
  88. // });
  89. instance = new Vue({
  90. router,
  91. store,
  92. i18n,
  93. render: (h) => h(App)
  94. }).$mount(container ? container.querySelector('#app') : '#app');
  95. }
  96. if (!window.__POWERED_BY_QIANKUN__) {
  97. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  98. render();
  99. }
  100. export async function bootstrap() {
  101. console.log('[vue] vue app bootstraped');
  102. }
  103. export async function mount(props) {
  104. console.log('[vue] props from main framework', props);
  105. Vue.prototype.$portalStore = props.store;
  106. initParentStore(props.store);
  107. // initParentStore(props.store?.state);
  108. props.onGlobalStateChange((state, prev) => {
  109. // state: 变更后的状态; prev 变更前的状态
  110. initParentStore(state);
  111. });
  112. render(props);
  113. }
  114. export async function unmount() {
  115. instance.$destroy();
  116. instance.$el.innerHTML = '';
  117. instance = null;
  118. }