Commit 936167e8 authored by lihonglin's avatar lihonglin

feat: 添加依赖

parent ce9f5690
Pipeline #46232 passed with stages
in 2 minutes 37 seconds
......@@ -2,11 +2,11 @@
import 'kit_logger';
import _ from 'lodash';
import {
addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted,
setDefaultMountApp,
start,
addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted,
setDefaultMountApp,
start,
} from 'qiankun';
import { store as microStore } from 'microser-data';
......@@ -21,30 +21,30 @@ import actions from './actions';
// eslint-disable-next-line no-undef
const Logger = logger('micro');
const MICRO_STATUS = {
NOT_LOADED: 'NOT_LOADED',
LOADING_SOURCE_CODE: 'LOADING_SOURCE_CODE',
NOT_BOOTSTRAPPED: 'NOT_BOOTSTRAPPED',
BOOTSTRAPPING: 'BOOTSTRAPPING',
NOT_MOUNTED: 'NOT_MOUNTED',
MOUNTING: 'MOUNTING',
MOUNTED: 'MOUNTED',
UPDATING: 'UPDATING',
UNMOUNTING: 'UNMOUNTING',
UNLOADING: 'UNLOADING',
SKIP_BECAUSE_BROKEN: 'SKIP_BECAUSE_BROKEN',
LOAD_ERROR: 'LOAD_ERROR',
NOT_LOADED: 'NOT_LOADED',
LOADING_SOURCE_CODE: 'LOADING_SOURCE_CODE',
NOT_BOOTSTRAPPED: 'NOT_BOOTSTRAPPED',
BOOTSTRAPPING: 'BOOTSTRAPPING',
NOT_MOUNTED: 'NOT_MOUNTED',
MOUNTING: 'MOUNTING',
MOUNTED: 'MOUNTED',
UPDATING: 'UPDATING',
UNMOUNTING: 'UNMOUNTING',
UNLOADING: 'UNLOADING',
SKIP_BECAUSE_BROKEN: 'SKIP_BECAUSE_BROKEN',
LOAD_ERROR: 'LOAD_ERROR',
};
export const initMicroApps = () => {
/* eslint-disable */
/* eslint-disable */
const config = window.globalConfig || {};
//createStoreage.get('globalConfig');
const application = config && config.products || [];
let products = [];
application && Array.isArray(application) && application.length > 0 && application.map(item => {
if(item.PackageName === 'report') {
if (item.PackageName === 'report') {
products.push({
name: item.PackageName,
entry: item.RouteUrl,
......@@ -67,13 +67,13 @@ export const initMicroApps = () => {
}
})
}
});
const entrys =
process.env.NODE_ENV !== 'production' ?
micorConfig.dev :
products;
micorConfig.dev :
products;
registerMicroApps(
entrys.map(item => {
item.loader = loader;
......@@ -83,50 +83,50 @@ export const initMicroApps = () => {
// eslint-
// disable-next-line no-undef
globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, {
homepage: config.homepage ? config.homepage.replace(/civweb\//, ''): config.homepage
}): config,
homepage: config.homepage ? config.homepage.replace(/civweb\//, '') : config.homepage
}) : config,
//createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest,
};
return item;
}), {
beforeLoad: [
app => {
store.dispatch(actionCreators.updateMicroMounted(true));
Logger.info('[LifeCycle] before load %c%s');
},
],
beforeMount: [
app => {
Logger.info(`[LifeCycle] before mount %c%s ${app.name}`);
},
],
afterMount: [
app => {
store.dispatch(actionCreators.updateMicroMounted(false));
Logger.info(`[LifeCycle] after mount %c%s ${app.name}`);
},
],
beforeUnmount: [
app => {
window.share.event.removeAllListeners('changeRoute');
Logger.info(`[LifeCycle] after unmount %c%s ${app.name}`);
window.globalConfig = {}
createStoreage.remove(`__PANDA_STORE__${location.hostname}`)
},
],
afterUnmount: [app => {}],
},
beforeLoad: [
app => {
store.dispatch(actionCreators.updateMicroMounted(true));
Logger.info('[LifeCycle] before load %c%s');
},
],
beforeMount: [
app => {
Logger.info(`[LifeCycle] before mount %c%s ${app.name}`);
},
],
afterMount: [
app => {
store.dispatch(actionCreators.updateMicroMounted(false));
Logger.info(`[LifeCycle] after mount %c%s ${app.name}`);
},
],
beforeUnmount: [
app => {
window.share.event.removeAllListeners('changeRoute');
Logger.info(`[LifeCycle] after unmount %c%s ${app.name}`);
window.globalConfig = {}
createStoreage.remove(`__PANDA_STORE__${location.hostname}`)
},
],
afterUnmount: [app => { }],
},
);
const globalStore = store.getState().toJS();
const globalConfig = window.globalConfig;
// globalConfig.homepage = globalConfig.homepage && /civweb4/.test(globalConfig.homepage) ? config.homepage.replace(/civweb4\//, ''): globalConfig.homepage;
actions.setGlobalState({
// eslint-disable-next-line no-undef
globalConfig: globalConfig,
globalConfig: globalConfig,
//createStoreage.get('globalConfig'),
});
microStore.set("props:globalConfig", {
globalConfig: globalConfig,
global: globalStore.global
......@@ -208,20 +208,20 @@ export const initMicroApps = () => {
export const defaultApp = () => {
// eslint-disable-next-line no-undef
const config = window.globalConfig;
if (config && config.token) {
// const basePath =config.homepage !== '' && FILTER_FOLER_REG.test(config.homepage) ?'civweb4' :'civweb4';
// if(config && config.home) {
// setDefaultMountApp(`/civbase/${config.home.path.replace(/^\//, '')}`);
// } else {
// const homepage = _.isNull(config.homepage) ? '/index': '/' + config.homepage;
// setDefaultMountApp(`/${pkg.name.toLocaleLowerCase()}/${basePath}${homepage}`);
// createStoreage.set('init_web4', true)
// }
// let homepage = config.homepage.replace('civweb4/', '');
const url = !config.home ? `/civbase/civweb4/${config.homepage.replace(/^\//, '').replace(/^civweb4\//, '')}`: `/civbase/${config.homepage.replace(/^\//, '')}`;
const url = !config.home ? `/civbase/civweb4/${config.homepage.replace(/^\//, '').replace(/^civweb4\//, '')}` : `/civbase/${config.homepage.replace(/^\//, '')}`;
setDefaultMountApp(url);
// if(config.homepage.indexOf('civweb4') > -1) createStoreage.set('init_web4', true);
}
......@@ -236,19 +236,19 @@ export const defaultApp = () => {
*/
window.app = {
modules: {},
require: function(request, method) {
if(request !== '.' && this.modules[request]) {
require: function (request, method) {
if (request !== '.' && this.modules[request]) {
console.log('method', method);
return _.isFunction(this.modules[request]) ? this.modules[request](): _.isFunction(this.modules[request][method]) && this.modules[request][method]();
return _.isFunction(this.modules[request]) ? this.modules[request]() : _.isFunction(this.modules[request][method]) && this.modules[request][method]();
}
if(request === '.') {
return
if (request === '.') {
return
}
return _.isFunction(this.modules[request]) && this.modules[request]();
},
define: function(name, context, index) {
define: function (name, context, index) {
let keys = context.keys();
for (let key of keys) {
let parts = name.indexOf('@') > -1 ? [name, ...(key.slice(1).split('/'))] : (name + key.slice(1)).split('/');
......@@ -267,7 +267,7 @@ window.app = {
this.modules[name] = this.modules[name][index];
}
},
init: function(namespace, reducers) {
init: function (namespace, reducers) {
[namespace] = reducers;
}
};
......@@ -483,6 +483,7 @@ window.app.define('@wisdom-utils/components', require.context('../node_modules/@
window.app.define('@ant-design/pro-form', require.context('../node_modules/@ant-design/pro-form/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
window.app.define('classnames', require.context('classnames', true, /^.\/index\.js$/), 'index.js');
window.app.define('@ant-design/icons', require.context('../node_modules/@ant-design/icons/lib', true, /^.\/(lib\/)?[^\/]+\.js$/), 'index.js');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment