main.js 3.0 KB

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