-
Notifications
You must be signed in to change notification settings - Fork 2k
/
index.js
44 lines (37 loc) 路 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @author Kuitos
* @since 2019-05-16
*/
import React from 'react';
import ReactDOM from 'react-dom';
import { runDefaultMountEffects } from '../../esm/effects';
import { registerMicroApps, start } from '../../esm/index';
import Framework from './Framework';
function render({ appContent, loading }) {
const container = document.getElementById('container');
ReactDOM.render(<Framework loading={loading} content={appContent}/>, container);
}
function genActiveRule(routerPrefix) {
return location => location.pathname.startsWith(routerPrefix);
}
render({ loading: true });
registerMicroApps(
[
{ name: 'react app', entry: '//localhost:7100', render, activeRule: genActiveRule('/react') },
{ name: 'react15 app', entry: '//localhost:7102', render, activeRule: genActiveRule('/15react15') },
{ name: 'vue app', entry: '//localhost:7101', render, activeRule: genActiveRule('/vue') },
],
{
beforeLoad: [app => {
console.log('before load', app);
}],
beforeMount: [app => {
console.log('before mount', app);
}],
afterUnmount: [app => {
console.log('after unload', app);
}],
},
);
runDefaultMountEffects('/react');
start();