|
|
@@ -9,6 +9,7 @@ import VueClipboard from 'vue-clipboard2';
|
|
|
import i18n from './i18n';
|
|
|
import './styles/index.scss';
|
|
|
import DictSelection from '@/components/Dict/DictSelection';
|
|
|
+import initParentStore from '../qiankun_config/store';
|
|
|
|
|
|
import HeaderTitle from '@/components/header-title';
|
|
|
Vue.component('HeaderTitle', HeaderTitle);
|
|
|
@@ -29,9 +30,47 @@ Vue.use(EleAdmin, {
|
|
|
Vue.use(permission);
|
|
|
Vue.use(VueClipboard);
|
|
|
|
|
|
-new Vue({
|
|
|
- router,
|
|
|
- store,
|
|
|
- i18n,
|
|
|
- render: (h) => h(App)
|
|
|
-}).$mount('#app');
|
|
|
+let instance = null;
|
|
|
+
|
|
|
+function render (props = {}) {
|
|
|
+ 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;
|
|
|
+}
|