12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import { registerMicroApps, start, runAfterFirstMounted, addGlobalUncaughtErrorHandler, loadMicroApp } from 'qiankun';
- import { apps } from './apps';
- import { getProps, initGlState } from './state';
- import { getToken } from '/@/utils/auth';
- function filterApps() {
- apps.forEach((item) => {
-
- item.props = getProps();
- console.log('主应用给子应用传的数据', item.props);
-
-
- item.activeRule = genActiveRule('/' + item.activeRule);
- });
- return apps;
- }
- function genActiveRule(routerPrefix) {
- return (location) => location.pathname.startsWith(routerPrefix);
- }
- function registerApps() {
- const _apps = filterApps();
- registerMicroApps(_apps, {
- beforeLoad: [
-
- (loadApp) => {
- console.log('before load', loadApp);
- },
- ],
- beforeMount: [
-
- (mountApp) => {
- console.log('before mount', mountApp);
- },
- ],
- afterMount: [
-
- (mountApp) => {
- console.log('before mount', mountApp);
- },
- ],
- afterUnmount: [
-
- (unloadApp) => {
- console.log('after unload', unloadApp);
- },
- ],
- });
-
-
-
- runAfterFirstMounted(() => console.log('开启监控'));
-
- addGlobalUncaughtErrorHandler((event) => console.log(event));
-
- initGlState({ token: getToken() });
-
- start({
- prefetch: 'all',
-
-
-
-
-
-
- sandbox: false,
- });
-
- }
- export { registerApps };
|