main.js 3.5 KB

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