main.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 {
  9. MAP_KEY,
  10. LICENSE_CODE
  11. } from '@/config/setting';
  12. import EleAdmin from 'ele-admin';
  13. import VueClipboard from 'vue-clipboard2';
  14. import i18n from './i18n';
  15. import './styles/index.scss';
  16. import '@/components/FormGenerator/styles/index.scss';
  17. import DictSelection from '@/components/Dict/DictSelection';
  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 authSelection from '@/components/authSelection';
  23. Vue.component('HeaderTitle', HeaderTitle);
  24. Vue.component('authSelection', authSelection);
  25. import Print from 'vue-printjs';
  26. Vue.use(Print);
  27. // // register globally
  28. Vue.component('tinymce', TinymceEditor);
  29. import '@/icons';
  30. import clickOnce from './utils/clickOnce.js';
  31. // 注册全局自定义指令
  32. Vue.directive('click-once', clickOnce);
  33. // bpmnProcessDesigner 需要引入
  34. import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
  35. Vue.use(MyPD);
  36. import '@/components/bpmnProcessDesigner/package/theme/index.scss';
  37. import 'bpmn-js/dist/assets/diagram-js.css';
  38. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
  39. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
  40. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
  41. // 引入公共方法
  42. import {
  43. handleInputPublicHasPoint,
  44. handleInputPublic
  45. } from './utils/inputHandler';
  46. Vue.prototype.$handleInputPublicHasPoint = handleInputPublicHasPoint;
  47. Vue.prototype.$handleInputPublic = handleInputPublic;
  48. Vue.component('DictSelection', DictSelection);
  49. Vue.config.productionTip = false;
  50. // 表单重置
  51. Vue.prototype.resetForm = function resetForm(refName) {
  52. if (this.$refs[refName]) {
  53. this.$refs[refName].resetFields();
  54. }
  55. };
  56. Vue.use(EleAdmin, {
  57. response: {
  58. dataName: 'list'
  59. },
  60. mapKey: MAP_KEY,
  61. license: LICENSE_CODE,
  62. i18n: (key, value) => i18n.t(key, value)
  63. });
  64. Vue.use(permission);
  65. Vue.use(VueClipboard);
  66. // new Vue({
  67. // router,
  68. // store,
  69. // i18n,
  70. // render: (h) => h(App)
  71. // }).$mount('#app');
  72. let instance = null;
  73. function render(props = {}) {
  74. const {
  75. container,
  76. routerBase
  77. } = props;
  78. // const router = new VueRouter({
  79. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  80. // mode: 'history',
  81. // routes
  82. // });
  83. instance = new Vue({
  84. router,
  85. store,
  86. i18n,
  87. render: (h) => h(App)
  88. }).$mount(container ? container.querySelector('#app') : '#app');
  89. }
  90. if (!window.__POWERED_BY_QIANKUN__) {
  91. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  92. render();
  93. }
  94. export async function bootstrap() {
  95. console.log('[vue] vue app bootstraped');
  96. }
  97. export async function mount(props) {
  98. console.log('[vue] props from main framework', props);
  99. Vue.prototype.$portalStore = 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. }