main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 DictSelection from '@/components/Dict/DictSelection';
  14. import HeaderTitle from '@/components/header-title';
  15. import authSelection from '@/components/authSelection';
  16. import Vue2OrgTree from 'vue2-org-tree';
  17. import seekPage from '@/BIZComponents/seekPage';
  18. import clickOnce from './utils/clickOnce.js';
  19. import noChinese from './utils/noChinese.js';
  20. import { VirtualScroller } from 'vue-virtual-scroller';
  21. import LimitDirective from './plugins/limit-plugin'
  22. import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
  23. Vue.component('virtual-scroller', VirtualScroller);
  24. import { all, create } from 'mathjs'; // 引入mathjs工具并初始化
  25. // 注册全局自定义指令
  26. Vue.directive('click-once', clickOnce);
  27. Vue.directive('no-chinese', noChinese);
  28. Vue.component('HeaderTitle', HeaderTitle);
  29. Vue.component('authSelection', authSelection);
  30. // // register globally
  31. import '@/icons';
  32. Vue.component('DictSelection', DictSelection);
  33. Vue.component('seekPage', seekPage);
  34. import tableScrollSync from '@/directives/tableScrollSync';
  35. Vue.directive('table-scroll-sync', tableScrollSync);
  36. Vue.config.productionTip = false;
  37. Vue.prototype.$math = create(all, {
  38. number: 'BigNumber',
  39. precision: 64
  40. });
  41. Vue.use(LimitDirective)
  42. Vue.use(Vue2OrgTree);
  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. let instance = null;
  54. // bpmnProcessDesigner 需要引入
  55. import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
  56. Vue.use(MyPD);
  57. import paramsDataMixins from './mixins/paramsDataMixins';
  58. Vue.mixin(paramsDataMixins);
  59. import '@/components/bpmnProcessDesigner/package/theme/index.scss';
  60. import 'bpmn-js/dist/assets/diagram-js.css';
  61. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
  62. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
  63. import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
  64. import fileMain from '@/components/addDoc/index.vue';
  65. import FormMaking from '../lib/vue-form-making/src/index';
  66. Vue.use(FormMaking, {
  67. lang: 'zh-CN',
  68. i18n: i18n
  69. });
  70. Vue.component('fileMain', fileMain);
  71. function render(props = {}) {
  72. const { container, routerBase } = props;
  73. // const router = new VueRouter({
  74. // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
  75. // mode: 'history',
  76. // routes
  77. // });
  78. instance = new Vue({
  79. router,
  80. store,
  81. i18n,
  82. render: (h) => h(App)
  83. }).$mount(container ? container.querySelector('#app') : '#app');
  84. }
  85. if (!window.__POWERED_BY_QIANKUN__) {
  86. // 这里是子应用独立运行的环境,实现子应用的登录逻辑
  87. render();
  88. }
  89. // window.location.reload()
  90. export async function bootstrap() {
  91. console.log('[vue] vue app bootstraped');
  92. }
  93. export async function mount(props) {
  94. console.log('[vue] props from main framework', props);
  95. Vue.prototype.$portalStore = props.store;
  96. initParentStore(props.store);
  97. props.onGlobalStateChange((state, prev) => {
  98. // state: 变更后的状态; prev 变更前的状态
  99. initParentStore(state);
  100. });
  101. render(props);
  102. }
  103. export async function unmount() {
  104. instance.$destroy();
  105. instance.$el.innerHTML = '';
  106. instance = null;
  107. }