Commit c9feb50a authored by 杨思琦's avatar 杨思琦

fix: 新增缓存

parent 7162bbfe
Pipeline #71452 passed with stages
...@@ -114,9 +114,9 @@ ...@@ -114,9 +114,9 @@
"@wisdom-map/arcgismap": "1.4.0-151", "@wisdom-map/arcgismap": "1.4.0-151",
"@wisdom-map/basemap": "1.1.0-24", "@wisdom-map/basemap": "1.1.0-24",
"@wisdom-map/util": "^1.0.28-0", "@wisdom-map/util": "^1.0.28-0",
"@wisdom-utils/components": "0.1.292", "@wisdom-utils/components": "0.1.297",
"@wisdom-utils/runtime": "0.0.41", "@wisdom-utils/runtime": "0.0.46",
"@wisdom-utils/utils": "0.1.332", "@wisdom-utils/utils": "0.1.337",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"antd": "4.21.2", "antd": "4.21.2",
"compression": "1.7.4", "compression": "1.7.4",
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
"pinyin-match": "^1.1.1", "pinyin-match": "^1.1.1",
"promise.prototype.finally": "^3.1.2", "promise.prototype.finally": "^3.1.2",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"qiankun": "^2.4.6", "qiankun": "2.7.8",
"qrcode.react": "^1.0.0", "qrcode.react": "^1.0.0",
"rc-cascader": "^2.3.2", "rc-cascader": "^2.3.2",
"rc-queue-anim": "^2.0.0", "rc-queue-anim": "^2.0.0",
......
/* eslint-disable global-require */
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Router, Switch } from '@wisdom-utils/runtime'; import { Router, Switch } from '@wisdom-utils/runtime';
import { helpers, event } from '@wisdom-utils/utils'; import { helpers, event } from '@wisdom-utils/utils';
import { AliveScope } from 'react-activation';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
// eslint-disable-next-line import/extensions // eslint-disable-next-line import/extensions
import { dyRoutes } from '../../routes/config'; import { dyRoutes } from '../../routes/config';
const pkg = require('../../../package.json'); const pkg = require('../../../package.json');
const { renderRoutes } = helpers; const { renderRoutes } = helpers;
const config = require('../../../config/config'); const config = require('../../../config/config');
...@@ -36,16 +35,31 @@ const App = props => { ...@@ -36,16 +35,31 @@ const App = props => {
{props?.global?.title && <meta name="description" content={`${props.global.title}`} />} {props?.global?.title && <meta name="description" content={`${props.global.title}`} />}
</Helmet> </Helmet>
<Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}> <Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}>
<Switch> {window?.qiankunIsCache ? (
{renderRoutes( <AliveScope>
'panda-console-base', <Switch>
dyRoutes( {renderRoutes(
props.menu || [], 'panda-console-base',
props.global && props.global.layout, dyRoutes(
(props.global && props.global.theme) || 'dark', props.menu || [],
).routes, props.global && props.global.layout,
)} (props.global && props.global.theme) || 'dark',
</Switch> ).routes,
)}
</Switch>
</AliveScope>
) : (
<Switch>
{renderRoutes(
'panda-console-base',
dyRoutes(
props.menu || [],
props.global && props.global.layout,
(props.global && props.global.theme) || 'dark',
).routes,
)}
</Switch>
)}
</Router> </Router>
</> </>
); );
...@@ -54,6 +68,7 @@ const App = props => { ...@@ -54,6 +68,7 @@ const App = props => {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']), menu: state.getIn(['global', 'menu']),
products: state.getIn(['global', 'products']),
flatMenu: state.getIn(['global', 'flatMenu']), flatMenu: state.getIn(['global', 'flatMenu']),
}); });
export default connect( export default connect(
......
...@@ -241,7 +241,7 @@ export function logout(data) { ...@@ -241,7 +241,7 @@ export function logout(data) {
window[products[item]].unmount({ store }); window[products[item]].unmount({ store });
}); });
} }
store.set('event:dropCache');
return { return {
type: LOGINOUT, type: LOGINOUT,
data: { data: {
......
...@@ -9,6 +9,11 @@ body, ...@@ -9,6 +9,11 @@ body,
} }
#app { #app {
background: transparent!important; background: transparent!important;
.ka-wrapper,
.ka-content{
width: 100%;
height: 100%;
}
} }
* { * {
margin: 0; margin: 0;
......
// @eslint-disable // @eslint-disable
import React, { Suspense, useEffect, useRef, useState } from 'react'; import React, { Suspense, useEffect, useRef, useState } from 'react';
import { Anchor, Popover, Radio, Spin } from 'antd'; import { Anchor, Modal, Popover, Radio, Spin } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import _ from 'lodash'; import _ from 'lodash';
...@@ -242,6 +242,13 @@ const transformFloatMenu = (routes, homepage) => { ...@@ -242,6 +242,13 @@ const transformFloatMenu = (routes, homepage) => {
return routes.concat(route); return routes.concat(route);
}; };
const finishInitWeb = homepage => {
event.emit('initweb', false);
typeof homepage === 'string' &&
homepage !== '' &&
window.history.replaceState({ delete: true }, null, `/civbase/${homepage}`);
};
const Layout = props => { const Layout = props => {
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams( const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams(
'client', 'client',
...@@ -254,6 +261,7 @@ const Layout = props => { ...@@ -254,6 +261,7 @@ const Layout = props => {
const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading)); const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading));
const [menuLoading, setMenuLoading] = useState(true); const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true); const [subLoading, setSubLoading] = useState(true);
const [initWebContent, setInitWebContent] = useState(false);
// const [settings, setSetting] = useState({}); // const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null); // const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState(''); // const [matchPath, setMatchPath] = useState('');
...@@ -271,6 +279,9 @@ const Layout = props => { ...@@ -271,6 +279,9 @@ const Layout = props => {
event.on('loading', ret => { event.on('loading', ret => {
setSubLoading(ret); setSubLoading(ret);
}); });
event.on('initweb', ret => {
setInitWebContent(ret);
});
}, []); }, []);
useEffect(() => { useEffect(() => {
...@@ -478,6 +489,24 @@ const Layout = props => { ...@@ -478,6 +489,24 @@ const Layout = props => {
<div id="micro-container" className="subapp-container"> <div id="micro-container" className="subapp-container">
{props.children} {props.children}
</div> </div>
<Modal
title={<div style={{ textAlign: 'center' }}>温馨提示</div>}
centered
width="333px"
visible={initWebContent}
cancelText="取消"
okText="确定"
onOk={() => {
finishInitWeb(props.global?.homepage ?? '');
}}
onCancel={() => {
finishInitWeb(props.global?.homepage ?? '');
}}
zIndex={2000}
>
缓存仅支持最新功能,若要体验完整版请进行相关功能升级,或点击确认完成初次兼容加载后再次进入功能即可
</Modal>
</BasicLayout> </BasicLayout>
</SecurityLayout> </SecurityLayout>
); );
......
...@@ -6,7 +6,9 @@ import PageLoading from '@wisdom-utils/components/lib/AppLayout/components/PageL ...@@ -6,7 +6,9 @@ import PageLoading from '@wisdom-utils/components/lib/AppLayout/components/PageL
import _ from 'lodash'; import _ from 'lodash';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import { store, helpers } from '@wisdom-utils/utils'; import { store, helpers } from '@wisdom-utils/utils';
import { ValidDefaultPWDContainer } from '@/components/Container' import { ValidDefaultPWDContainer } from '@/components/Container';
import { initSaveMicroApps } from '../micro';
class SecurityLayout extends React.Component { class SecurityLayout extends React.Component {
state = { state = {
isReady: false, isReady: false,
...@@ -22,66 +24,76 @@ class SecurityLayout extends React.Component { ...@@ -22,66 +24,76 @@ class SecurityLayout extends React.Component {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const products = (this.props.global.products || []).map(item => { const products = (this.props.global.products || []).map(item => {
if (item.PackageName === 'civweb4') { if (item.PackageName === 'civweb4') {
return 'web4_console' return 'web4_console';
} }
return `${item.PackageName}-main`; return `${item.PackageName}-main`;
}); });
const location = this.props.location; const { location } = this.props;
const pathname = location.pathname; const { pathname } = location;
const argv = pathname.split('/'); const argv = pathname.split('/');
const nextPathname = nextProps.location.pathname; const nextPathname = nextProps.location.pathname;
const nextArgv = nextPathname.split('/'); const nextArgv = nextPathname.split('/');
if (argv[2] !== nextArgv[2]) { if (argv[2] !== nextArgv[2]) {
Object.keys(products).forEach(item => { Object.keys(products).forEach(item => {
window[products[item]] && window[products[item]] && window[products[item]].unmount && window[products[item]].unmount({ store: store }); window[products[item]] &&
window[products[item]] &&
window[products[item]].unmount &&
window[products[item]].unmount({ store });
}); });
} }
if (this.props.location.pathname !== nextProps.location.pathname) { if (this.props.location.pathname !== nextProps.location.pathname) {
store.set('event:globalConfig', { globalConfig: nextProps.global }); if (window?.qiankunIsCache) {
const marks = document.querySelectorAll('#micro-container');
if (marks && marks.length) {
const activeAppPath = nextProps.location.pathname.match(/(\w+)/)
? nextProps.location.pathname.match(/(\w+)/)[0]
: null;
if (activeAppPath) {
initSaveMicroApps(nextProps.location.pathname, nextProps.global);
}
}
} else {
store.set('event:globalConfig', { globalConfig: nextProps.global });
}
} }
} }
render() { render() {
const { isReady } = this.state; const { isReady } = this.state;
const { children, global, loading } = this.props; const { children, global, loading } = this.props;
const tk = Cookies.get('token') || global.token; const tk = Cookies.get('token') || global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0); const isLogin = tk !== null && tk !== 'undefined' && tk !== void 0;
const { pathname } = history.location;
if (!isLogin && window.location.pathname !== '/civbase/user/login' || (global.hasOwnProperty('size') && global.size === 0)) { if (
const { query = {}, search, pathname } = history.location; (!isLogin && window.location.pathname !== '/civbase/user/login') ||
const { redirect } = query; // eslint-disable-next-line no-prototype-builtins
// const queryString = stringify({ (global.hasOwnProperty('size') && global.size === 0)
// redirect: pathname + search, ) {
// });
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0); this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || sessionStorage.getItem('client'); let client = global.client || sessionStorage.getItem('client');
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city'; client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
let { generateType } = global; let { generateType } = global;
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : ''; generateType =
!_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined'
? `&generateType=${generateType}`
: '';
// eslint-disable-next-line prettier/prettier
window.qiankunStarted = false;
return ( return (
<Redirect <Redirect to={{ pathname: `/user/login?client=${client}${generateType}`, state: { reload: true } }} exact />
to={{pathname: `/user/login?client=${client}${generateType}`, state:{reload: true}}}
/>
); );
}; }
if ((!isLogin && loading) || !isReady) { if ((!isLogin && loading) || !isReady) {
return <PageLoading />; return <PageLoading />;
} }
return ( return <ValidDefaultPWDContainer>{children}</ValidDefaultPWDContainer>;
<ValidDefaultPWDContainer>
{children}
</ValidDefaultPWDContainer>
);
} }
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']), global: state.getIn(['global', 'globalConfig']),
location: state.getIn(['router', 'location']).toJS() location: state.getIn(['router', 'location']).toJS(),
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -2,9 +2,11 @@ import '@wisdom-utils/utils/lib/logger'; ...@@ -2,9 +2,11 @@ import '@wisdom-utils/utils/lib/logger';
import _ from 'lodash'; import _ from 'lodash';
import { import {
addGlobalUncaughtErrorHandler, addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted, runAfterFirstMounted,
registerMicroApps,
setDefaultMountApp, setDefaultMountApp,
loadMicroApp,
prefetchApps,
start, start,
} from 'qiankun'; } from 'qiankun';
import { event, store as microStore } from '@wisdom-utils/utils'; import { event, store as microStore } from '@wisdom-utils/utils';
...@@ -19,213 +21,254 @@ const xss = require('xss'); ...@@ -19,213 +21,254 @@ const xss = require('xss');
const { processComponentName } = string; const { processComponentName } = string;
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const Logger = logger('micro'); const Logger = logger('micro');
let micorManager = [];
let web4Load = false;
export const Configuration = {
sandbox: {
experimentalStyleIsolation: false,
loose: true,
},
singular: false,
scopedCSS: true,
prefetch: 'all',
getTemplate(tpl) {
return tpl.replace(
'<script language="javascript">setURL("18.10.10.253");supFlash(getVersion("td_cookie"));</script>',
'',
);
},
async fetch(url, ...args) {
if (url.indexOf('cookie/flash.js') > -1) {
return {
async text() {
return '';
},
};
}
return window.fetch(url, ...args);
},
// eslint-disable-next-line no-underscore-dangle
excludeAssetFilter: url =>
url.indexOf('framework/highcharts') !== -1 ||
// url.indexOf('framework/amap/AMap.UI') !== -1 ||
// url.indexOf('framework/4.9/init.js') !== -1 ||
url.indexOf('DataPresentation.js') !== -1 ||
url.indexOf('jquery-mousewheel-easyui-qrcode-cookie-resize-filesaver-fisheye-dateFormat-gridify.js') !== -1 ||
url.indexOf('jquery') !== -1 ||
url.indexOf('components/filetools/xlsx.core.min') !== -1 ||
url.indexOf('managers/MapManager.js') !== -1 ||
url.indexOf('jquery.mCustomScrollbar.js') !== -1 ||
url.indexOf('QIAN_KUN_Platform.js') !== -1 ||
url.indexOf('configuration/js') !== -1 ||
url.indexOf('framework/three.js') !== -1 ||
url.indexOf('threedimensional/frameworkthree') !== -1 ||
url.indexOf('iframe/Civ3DLLab/js') !== -1 ||
url.indexOf('framework/jquery/gridify-min.js') !== -1 ||
url.indexOf('framework/jquery/gridify.qrcode.js') !== -1 ||
url.indexOf('framework/application/Platform.js') !== -1 ||
url.indexOf('webgisPanda/AMapTool') !== -1 ||
url.indexOf('framework/underscore') !== -1 ||
url.indexOf('echarts') !== -1 ||
url.indexOf('lbs.amap.com') !== -1 ||
url.indexOf('restapi.amap.com') !== -1 ||
url.indexOf('webapi.amap.com') !== -1 ||
url.indexOf('webapi.amap.com/count') !== -1 ||
url.indexOf('webapi.amap.com/maps') !== -1 ||
url.indexOf('restapi.amap.com/v3') !== -1 ||
url.indexOf('api.map.baidu.com') !== -1 ||
url.indexOf('map.baidu.com') !== -1 ||
url.indexOf('pv.sohu.com') !== -1 ||
url.indexOf('mt0.google.cn') !== -1 ||
url.indexOf('mt1.google.cn') !== -1 ||
url.indexOf('mt2.google.cn') !== -1 ||
url.indexOf('mt3.google.cn') !== -1 ||
url.indexOf('hm.baidu.com') !== -1 ||
url.indexOf('framework/antv/antvL7.min.js') !== -1 ||
url.indexOf('https://maponline0.bdimg.com') !== -1 ||
url.indexOf('https://maponline1.bdimg.com') !== -1 ||
url.indexOf('https://maponline2.bdimg.com') !== -1 ||
url.indexOf('https://maponline3.bdimg.com') !== -1 ||
url.indexOf('https://api.map.baidu.com/getscript') !== -1 ||
url.indexOf('dlswbr.baidu.com') !== -1 ||
url.indexOf('maponline0.bdimg.com') !== -1 ||
url.indexOf('miao.baidu.com') !== -1,
};
export const initMicroApps = () => { export const LifeCycle = {
/* eslint-disable */ beforeLoad: [
const config = window.globalConfig || {}; app => {
const application = config && config.products || []; store.dispatch(actionCreators.updateMicroMounted(true));
let products = []; Logger.info('[LifeCycle] before load %c%s', app);
},
],
application && Array.isArray(application) && application.length > 0 && application.map(item => { beforeMount: [
if (item.PackageName === 'report') { app => {
products.push({ microStore.off('event:globalConfig', () => {});
name: item.PackageName, Logger.info(`[LifeCycle] before mount %c%s ${app.name}`, app);
entry: item.RouteUrl, },
container: '#micro-container', ],
activeRule: genActiveRule(`/civbase/${item.PackageName}`), afterMount: [
props: { app => {
...item.DefaultSetting, store.dispatch(actionCreators.updateMicroMounted(false));
routerBase: item.PackageName, Logger.info(`[LifeCycle] after mount %c%s ${app.name}`, app);
event: event, },
store: microStore ],
} beforeUnmount: [
}) app => {
} else { window.share.event.removeAllListeners('changeRoute');
products.push({ Logger.info(`[LifeCycle] beforeUnmount %c%s ${app.name}`, app);
name: item.PackageName, // window.globalConfig = {}
entry: window.location.protocol + "//" + window.location.host + (`/${item.PackageName}`), // createStoreage.remove(`__PANDA_STORE__${location.hostname}`)
container: '#micro-container', },
activeRule: genActiveRule(`/civbase/${item.PackageName}`), ],
props: { afterUnmount: [
...item.DefaultSetting, app => {
routerBase: item.PackageName, actions.offGlobalStateChange();
event: event, Logger.info(`[LifeCycle] after unmount %c%s ${app.name}`, app);
store: microStore },
} ],
}) };
}
export const application = global => {
const config = global || window.globalConfig || {};
const applications = (config && config.products) || [];
const products = [];
applications &&
Array.isArray(applications) &&
applications.length > 0 &&
applications.map(item => {
if (item.PackageName === 'report') {
products.push({
name: item.PackageName,
entry: item.RouteUrl,
container: '#micro-container',
activeRule: genActiveRule(`/civbase/${item.PackageName}`),
props: {
...item.DefaultSetting,
routerBase: item.PackageName,
event,
store: microStore,
},
});
} else {
products.push({
name: item.PackageName,
entry: `${window.location.protocol}//${window.location.host}/${item.PackageName}`,
container: '#micro-container',
activeRule: genActiveRule(`/civbase/${item.PackageName}`),
props: {
...item.DefaultSetting,
routerBase: item.PackageName,
event,
store: microStore,
},
});
}
}); });
const entrys = const entrys = process.env.NODE_ENV !== 'production' ? micorConfig.dev : products;
process.env.NODE_ENV !== 'production' ?
micorConfig.dev : const apps = entrys.map(item => ({
products; ...item,
props: {
const apps = entrys.map(item => { emitter: window.share.event,
return { baseRoot: item.name,
...item, event,
props: { store: microStore,
emitter: window.share.event, // eslint-disable-next-line prettier/prettier
baseRoot: item.name, globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, {homepage: config.homepage ? config.homepage.replace(/civweb\//, '') : config.homepage,}) : config,
event: event, // createStoreage.get('globalConfig'),
store: microStore, XMLHttpRequest: window.XMLHttpRequest,
// eslint- // offGlobalStateChange: actions.offGlobalStateChange
// disable-next-line no-undef },
globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, { loader,
homepage: config.homepage ? config.homepage.replace(/civweb\//, '') : config.homepage }));
}) : config,
//createStoreage.get('globalConfig'), return apps;
XMLHttpRequest: window.XMLHttpRequest, };
// offGlobalStateChange: actions.offGlobalStateChange
export const initSaveMicroApps = (pathName = '', global) => {
/* eslint-disable */
event.emit('loading', false);
setTimeout(() => {
const microApps = application(global);
const micro = microApps.filter(app => !/civweb4/.test(app.name)) ?? [];
if(/civweb4/.test(pathName) && !web4Load) {
event.emit("initweb", true);
micro.map((app) => {
const filter = micorManager.filter(mic => typeof(app.name) === 'string' && app.name.indexOf(mic.name) >= 0) ?? []
if(filter.length === 0) {
micorManager.push({
...loadMicroApp(app, Configuration, LifeCycle),
name: app?.name,
store: app?.props?.store
})
}
})
web4Load = true;
} else {
const target = micorManager.slice(-1)[0] ?? null;
if(!target || pathName.indexOf(target.name) == -1) {
const microApp = microApps.filter(app => pathName.indexOf(app.name) > -1)[0] ?? null;
if(microApp) micorManager.push({
...loadMicroApp(microApp, Configuration, LifeCycle),
name: microApp?.name,
store: microApp?.props?.store
})
} }
} }
}) })
};
const microApps = apps.map((app => ({ export const initMicroApps = (url) => {
...app, if(!window.qiankunStarted) {
loader, // /* eslint-disable */
})))
registerMicroApps(microApps, {
beforeLoad: [
app => {
store.dispatch(actionCreators.updateMicroMounted(true));
Logger.info('[LifeCycle] before load %c%s', app);
},
],
beforeMount: [
app => {
microStore.off("event:globalConfig", () => {});
Logger.info(`[LifeCycle] before mount %c%s ${app.name}`, app);
},
],
afterMount: [
app => {
store.dispatch(actionCreators.updateMicroMounted(false));
Logger.info(`[LifeCycle] after mount %c%s ${app.name}`, app);
},
],
beforeUnmount: [
app => {
window.share.event.removeAllListeners('changeRoute');
Logger.info(`[LifeCycle] beforeUnmount %c%s ${app.name}`, app);
// window.globalConfig = {}
// createStoreage.remove(`__PANDA_STORE__${location.hostname}`)
},
],
afterUnmount: [app => {
actions.offGlobalStateChange();
Logger.info(`[LifeCycle] after unmount %c%s ${app.name}`, app);
}],
},
);
const globalStore = store.getState().toJS(); const globalStore = store.getState().toJS();
const globalConfig = window.globalConfig; const globalConfig = window.globalConfig;
// globalConfig.homepage = globalConfig.homepage && /civweb4/.test(globalConfig.homepage) ? config.homepage.replace(/civweb4\//, ''): globalConfig.homepage;
// actions.offGlobalStateChange();
// actions.setGlobalState({
// // eslint-disable-next-line no-undef
// globalConfig: globalConfig
// //createStoreage.get('globalConfig'),
// });
// actions.offGlobalStateChange();
microStore.set("event:globalConfig", { microStore.set("event:globalConfig", {
globalConfig: globalConfig, globalConfig: globalConfig,
global: globalStore.global global: globalStore.globalf
}); });
start({ const microApps = application();
sandbox: { const micro = microApps.filter(app => (!/civweb4/.test(app.name) && url.indexOf(app.name) < 0)) ?? [];
experimentalStyleIsolation: false, if(window?.qiankunIsCache){
loose: true, microStore.on("event:dropCache", (() => {
}, micorManager.map((micro) => {
singular: false, micro.unmount ?? micro.unmount();
scopedCSS: true, })
prefetch: 'all', micorManager = [];
getTemplate(tpl) { }));
return tpl.replace('<script language="javascript">setURL("18.10.10.253");supFlash(getVersion("td_cookie"));</script>', ''); window.qiankunStarted = true;
}, start(Configuration);
async fetch(url, ...args) { setTimeout(() => {
if (url.indexOf('cookie/flash.js') > -1) { initSaveMicroApps(url);
return { })
async text() { runAfterFirstMounted(() => {
return ''; prefetchApps(micro);
},
};
}
return window.fetch(url, ...args);
},
// eslint-disable-next-line no-underscore-dangle
// getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
excludeAssetFilter: url =>
url.indexOf('framework/highcharts') !== -1 ||
// url.indexOf('framework/amap/AMap.UI') !== -1 ||
// url.indexOf('framework/4.9/init.js') !== -1 ||
url.indexOf('DataPresentation.js') !== -1 ||
url.indexOf('jquery-mousewheel-easyui-qrcode-cookie-resize-filesaver-fisheye-dateFormat-gridify.js') !== -1 ||
url.indexOf('jquery') !== -1 ||
url.indexOf('components/filetools/xlsx.core.min') !== -1 ||
url.indexOf('managers/MapManager.js') !== -1 ||
url.indexOf('jquery.mCustomScrollbar.js') !== -1 ||
url.indexOf('QIAN_KUN_Platform.js') !== -1 ||
url.indexOf('configuration/js') !== -1 ||
url.indexOf('framework/three.js') !== -1 ||
url.indexOf('threedimensional/frameworkthree') !== -1 ||
url.indexOf('iframe/Civ3DLLab/js') !== -1 ||
url.indexOf('framework/jquery/gridify-min.js') !== -1 ||
url.indexOf('framework/jquery/gridify.qrcode.js') !== -1 ||
url.indexOf('framework/application/Platform.js') !== -1 ||
url.indexOf('webgisPanda/AMapTool') !== -1 ||
url.indexOf('framework/underscore') !== -1 ||
url.indexOf('echarts') !== -1 ||
url.indexOf('lbs.amap.com') !== -1 ||
url.indexOf('restapi.amap.com') !== -1 ||
url.indexOf('webapi.amap.com') !== -1 ||
url.indexOf('webapi.amap.com/count') !== -1 ||
url.indexOf('webapi.amap.com/maps') !== -1 ||
url.indexOf('restapi.amap.com/v3') !== -1 ||
url.indexOf('api.map.baidu.com') !== -1 ||
url.indexOf('map.baidu.com') !== -1 ||
url.indexOf('pv.sohu.com') !== -1 ||
url.indexOf('mt0.google.cn') !== -1 ||
url.indexOf('mt1.google.cn') !== -1 ||
url.indexOf('mt2.google.cn') !== -1 ||
url.indexOf('mt3.google.cn') !== -1 ||
url.indexOf('hm.baidu.com') !== -1 ||
url.indexOf('framework/antv/antvL7.min.js') !== -1 ||
url.indexOf('https://maponline0.bdimg.com') !== -1 ||
url.indexOf('https://maponline1.bdimg.com') !== -1 ||
url.indexOf('https://maponline2.bdimg.com') !== -1 ||
url.indexOf('https://maponline3.bdimg.com') !== -1 ||
url.indexOf('https://api.map.baidu.com/getscript') !== -1 ||
url.indexOf('dlswbr.baidu.com') !== -1 ||
url.indexOf('maponline0.bdimg.com') !== -1 ||
url.indexOf('miao.baidu.com') !== -1,
});
runAfterFirstMounted(() => {
Logger.info('[MainApp] first app mounted'); Logger.info('[MainApp] first app mounted');
}); });
// eslint-disable-next-line no-use-before-define addGlobalUncaughtErrorHandler(event => {
// defaultApp();
addGlobalUncaughtErrorHandler(event => {
console.log(event); console.log(event);
});
}); } else {
window.qiankunStarted = true;
registerMicroApps(microApps, LifeCycle);
start(Configuration);
addGlobalUncaughtErrorHandler(event => {
console.log(event);
});
}
}
}; };
export const defaultApp = (setUrl) => { export const defaultApp = (setUrl) => {
const globalStore = store.getState().toJS();
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const config = window.globalConfig; const config = window.globalConfig;
// const flatMenu = globalStore.global.flatMenu;
// const current = flatMenu.find(item => item.name === '首页');
// config.homepage = current.path;
if (config && config.token) { if (config && config.token) {
let url = !config.home ? let url = !config.home ?
((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`; ((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`;
initMicroApps(setUrl || url);
setDefaultMountApp(setUrl || url); setDefaultMountApp(setUrl || url);
micorManager = [];
window.share.event.emit('visible', setUrl || url); window.share.event.emit('visible', setUrl || url);
} }
}; };
......
...@@ -58,7 +58,7 @@ const LoginTemplate = { ...@@ -58,7 +58,7 @@ const LoginTemplate = {
export default (props) => { export default (props) => {
const {location} = props.history; const {location} = props.history;
useEffect(() => { useEffect(() => {
if(location.state && location.state.reload) { if(location.state && location.state.reload && !window.qiankunIsCache) {
AppInitState(); AppInitState();
} }
}, []); }, []);
......
...@@ -368,20 +368,16 @@ class Login { ...@@ -368,20 +368,16 @@ class Login {
const homeType = config.productType || 'civweb4'; const homeType = config.productType || 'civweb4';
// 产品类型和首页路径同时有才行 // 产品类型和首页路径同时有才行
// eslint-disable-next-line prettier/prettier // eslint-disable-next-line prettier/prettier
const homepage = params.getParams('homepage') const homepage = params.getParams('homepage') ? params.getParams('homepage') : homeType && config.homepage ? `${homeType}/${params.getParams('homepage') || config.homepage}` : '';
? params.getParams('homepage') window.qiankunIsCache = config.isCache || false;
: homeType && config.homepage
? `${homeType}/${params.getParams('homepage') || config.homepage}`
: '';
self.globalConfig = Object.assign(self.globalConfig, config, { self.globalConfig = Object.assign(self.globalConfig, config, {
theme: self.globalConfig.theme, theme: self.globalConfig.theme,
menu: self.globalConfig.menu, menu: self.globalConfig.menu,
style: self.globalConfig.style, style: self.globalConfig.style,
homepage: homepage || '', homepage: homepage || '',
products: self.globalConfig.products,
// mapsettings: config.mapsettings // mapsettings: config.mapsettings
}); });
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then(res => { self.getProjectItems().then(res => {
window.subSysCfg = {}; window.subSysCfg = {};
......
const pkg = require('../package.json'); const pkg = require('../package.json');
window.arcgisAssetsPath = `${ window.location.origin}/${pkg.name.toLocaleLowerCase()}`; window.arcgisAssetsPath = `${window.location.origin}/${pkg.name.toLocaleLowerCase()}`;
\ No newline at end of file
...@@ -167,7 +167,6 @@ export const AppInitState = () => { ...@@ -167,7 +167,6 @@ export const AppInitState = () => {
window[products[item]].unmount && window[products[item]].unmount &&
window[products[item]].unmount({ store }); window[products[item]].unmount({ store });
}); });
initMicroApps();
} }
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
// 增加免登判定 // 增加免登判定
...@@ -189,11 +188,11 @@ export const AppInitState = () => { ...@@ -189,11 +188,11 @@ export const AppInitState = () => {
logout: () => store.dispatch(actionCreators.logout()), logout: () => store.dispatch(actionCreators.logout()),
}, },
() => { () => {
(async () => { // (async () => {
(await (getToken() && window.globalConfig && window.globalConfig.token)) && // (await (getToken() && window.globalConfig && window.globalConfig.token)) &&
// eslint-disable-next-line no-use-before-define // // eslint-disable-next-line no-use-before-define
initMicroApps(loader, store); // initMicroApps(loader, store);
})(); // })();
}, },
true, true,
); );
......
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