|
|
@@ -1,4 +1,6 @@
|
|
|
import Vue from 'vue';
|
|
|
+import './public-path';
|
|
|
+import initParentStore from '../qiankun_config/store';
|
|
|
import App from './App.vue';
|
|
|
import store from './store';
|
|
|
import router from './router';
|
|
|
@@ -28,10 +30,48 @@ Vue.use(EleAdmin, {
|
|
|
});
|
|
|
Vue.use(permission);
|
|
|
Vue.use(VueClipboard);
|
|
|
+let instance = null;
|
|
|
|
|
|
-new Vue({
|
|
|
- router,
|
|
|
- store,
|
|
|
- i18n,
|
|
|
- render: (h) => h(App)
|
|
|
-}).$mount('#app');
|
|
|
+function render (props = {}) {
|
|
|
+ console.log(router, 2222);
|
|
|
+ const { container, routerBase } = props;
|
|
|
+ // const router = new VueRouter({
|
|
|
+ // base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
|
|
|
+ // mode: 'history',
|
|
|
+ // routes
|
|
|
+ // });
|
|
|
+
|
|
|
+ instance = new Vue({
|
|
|
+ router,
|
|
|
+ store,
|
|
|
+ i18n,
|
|
|
+ render: (h) => h(App)
|
|
|
+ }).$mount(container ? container.querySelector('#app') : '#app');
|
|
|
+}
|
|
|
+
|
|
|
+if (!window.__POWERED_BY_QIANKUN__) {
|
|
|
+ // 这里是子应用独立运行的环境,实现子应用的登录逻辑
|
|
|
+ render();
|
|
|
+}
|
|
|
+
|
|
|
+export async function bootstrap () {
|
|
|
+ console.log('[vue] vue app bootstraped');
|
|
|
+}
|
|
|
+
|
|
|
+export async function mount (props) {
|
|
|
+ console.log('[vue] props from main framework', props);
|
|
|
+
|
|
|
+ initParentStore(props.store);
|
|
|
+ props.onGlobalStateChange((state, prev) => {
|
|
|
+ // state: 变更后的状态; prev 变更前的状态
|
|
|
+ initParentStore(state);
|
|
|
+ });
|
|
|
+
|
|
|
+ render(props);
|
|
|
+}
|
|
|
+
|
|
|
+export async function unmount () {
|
|
|
+ instance.$destroy();
|
|
|
+ instance.$el.innerHTML = '';
|
|
|
+ instance = null;
|
|
|
+}
|