main.js 3.1 KB

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