main.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Vue from 'vue';
  2. import App from './App.vue';
  3. import VueRouter from 'vue-router';
  4. import routes from './router';
  5. import store from './store';
  6. import ElementUI from 'element-ui';
  7. import 'element-ui/lib/theme-chalk/index.css';
  8. import './public-path.js';
  9. import dict from '@lib/dict.js';
  10. import tree from '@lib/tree.js';
  11. import resChange from '@lib/resChange.js';
  12. Vue.config.productionTip = false;
  13. Vue.use(VueRouter);
  14. Vue.use(ElementUI);
  15. Vue.use(dict);
  16. Vue.use(tree);
  17. Vue.use(resChange);
  18. let router = null;
  19. let instance = null;
  20. function render (props = {}) {
  21. const { container } = props;
  22. router = new VueRouter({
  23. base: window.__POWERED_BY_QIANKUN__ ? '/admin/discuss/' : '/',
  24. mode: 'history',
  25. routes
  26. });
  27. instance = new Vue({
  28. router,
  29. store,
  30. render: (h) => h(App)
  31. }).$mount(container ? container.querySelector('#app') : '#app');
  32. }
  33. // 独立运行时
  34. if (!window.__POWERED_BY_QIANKUN__) {
  35. render();
  36. }
  37. export async function bootstrap () {}
  38. export async function mount (props) {
  39. render(props);
  40. }
  41. export async function unmount () {
  42. instance.$destroy();
  43. instance.$el.innerHTML = '';
  44. instance = null;
  45. router = null;
  46. }