main.js 3.8 KB

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