main.js 3.2 KB

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