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

fix: 新增缓存

parent 7162bbfe
Pipeline #71452 passed with stages
......@@ -114,9 +114,9 @@
"@wisdom-map/arcgismap": "1.4.0-151",
"@wisdom-map/basemap": "1.1.0-24",
"@wisdom-map/util": "^1.0.28-0",
"@wisdom-utils/components": "0.1.292",
"@wisdom-utils/runtime": "0.0.41",
"@wisdom-utils/utils": "0.1.332",
"@wisdom-utils/components": "0.1.297",
"@wisdom-utils/runtime": "0.0.46",
"@wisdom-utils/utils": "0.1.337",
"animate.css": "^4.1.1",
"antd": "4.21.2",
"compression": "1.7.4",
......@@ -140,7 +140,7 @@
"pinyin-match": "^1.1.1",
"promise.prototype.finally": "^3.1.2",
"prop-types": "15.7.2",
"qiankun": "^2.4.6",
"qiankun": "2.7.8",
"qrcode.react": "^1.0.0",
"rc-cascader": "^2.3.2",
"rc-queue-anim": "^2.0.0",
......
/* eslint-disable global-require */
import React, { useEffect } from 'react';
import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
import { Router, Switch } from '@wisdom-utils/runtime';
import { helpers, event } from '@wisdom-utils/utils';
import { AliveScope } from 'react-activation';
import defaultSetting from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
// eslint-disable-next-line import/extensions
import { dyRoutes } from '../../routes/config';
const pkg = require('../../../package.json');
const { renderRoutes } = helpers;
const config = require('../../../config/config');
......@@ -36,16 +35,31 @@ const App = props => {
{props?.global?.title && <meta name="description" content={`${props.global.title}`} />}
</Helmet>
<Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}>
<Switch>
{renderRoutes(
'panda-console-base',
dyRoutes(
props.menu || [],
props.global && props.global.layout,
(props.global && props.global.theme) || 'dark',
).routes,
)}
</Switch>
{window?.qiankunIsCache ? (
<AliveScope>
<Switch>
{renderRoutes(
'panda-console-base',
dyRoutes(
props.menu || [],
props.global && props.global.layout,
(props.global && props.global.theme) || 'dark',
).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>
</>
);
......@@ -54,6 +68,7 @@ const App = props => {
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
menu: state.getIn(['global', 'menu']),
products: state.getIn(['global', 'products']),
flatMenu: state.getIn(['global', 'flatMenu']),
});
export default connect(
......
......@@ -241,7 +241,7 @@ export function logout(data) {
window[products[item]].unmount({ store });
});
}
store.set('event:dropCache');
return {
type: LOGINOUT,
data: {
......
......@@ -9,6 +9,11 @@ body,
}
#app {
background: transparent!important;
.ka-wrapper,
.ka-content{
width: 100%;
height: 100%;
}
}
* {
margin: 0;
......
// @eslint-disable
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 Cookies from 'js-cookie';
import _ from 'lodash';
......@@ -242,6 +242,13 @@ const transformFloatMenu = (routes, homepage) => {
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 currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${params.getParams(
'client',
......@@ -254,6 +261,7 @@ const Layout = props => {
const [siteAction, setSiteAction] = useState(() => new Site(props, setSiteLoading));
const [menuLoading, setMenuLoading] = useState(true);
const [subLoading, setSubLoading] = useState(true);
const [initWebContent, setInitWebContent] = useState(false);
// const [settings, setSetting] = useState({});
// const [routeConfig, setRouteConfig] = useState(null);
// const [matchPath, setMatchPath] = useState('');
......@@ -271,6 +279,9 @@ const Layout = props => {
event.on('loading', ret => {
setSubLoading(ret);
});
event.on('initweb', ret => {
setInitWebContent(ret);
});
}, []);
useEffect(() => {
......@@ -478,6 +489,24 @@ const Layout = props => {
<div id="micro-container" className="subapp-container">
{props.children}
</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>
</SecurityLayout>
);
......
......@@ -6,7 +6,9 @@ import PageLoading from '@wisdom-utils/components/lib/AppLayout/components/PageL
import _ from 'lodash';
import { stringify } from 'querystring';
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 {
state = {
isReady: false,
......@@ -22,66 +24,76 @@ class SecurityLayout extends React.Component {
componentWillReceiveProps(nextProps) {
const products = (this.props.global.products || []).map(item => {
if (item.PackageName === 'civweb4') {
return 'web4_console'
return 'web4_console';
}
return `${item.PackageName}-main`;
});
const location = this.props.location;
const pathname = location.pathname;
const { location } = this.props;
const { pathname } = location;
const argv = pathname.split('/');
const nextPathname = nextProps.location.pathname;
const nextArgv = nextPathname.split('/');
if (argv[2] !== nextArgv[2]) {
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) {
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() {
const { isReady } = this.state;
const { children, global, loading } = this.props;
const tk = Cookies.get('token') || global.token;
const isLogin = tk !== null && tk !== 'undefined' && tk !== (void 0);
if (!isLogin && window.location.pathname !== '/civbase/user/login' || (global.hasOwnProperty('size') && global.size === 0)) {
const { query = {}, search, pathname } = history.location;
const { redirect } = query;
// const queryString = stringify({
// redirect: pathname + search,
// });
const isLogin = tk !== null && tk !== 'undefined' && tk !== void 0;
const { pathname } = history.location;
if (
(!isLogin && window.location.pathname !== '/civbase/user/login') ||
// eslint-disable-next-line no-prototype-builtins
(global.hasOwnProperty('size') && global.size === 0)
) {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || sessionStorage.getItem('client');
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
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 (
<Redirect
to={{pathname: `/user/login?client=${client}${generateType}`, state:{reload: true}}}
/>
<Redirect to={{ pathname: `/user/login?client=${client}${generateType}`, state: { reload: true } }} exact />
);
};
}
if ((!isLogin && loading) || !isReady) {
return <PageLoading />;
}
return (
<ValidDefaultPWDContainer>
{children}
</ValidDefaultPWDContainer>
);
return <ValidDefaultPWDContainer>{children}</ValidDefaultPWDContainer>;
}
}
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
location: state.getIn(['router', 'location']).toJS()
location: state.getIn(['router', 'location']).toJS(),
});
export default connect(
mapStateToProps,
......
......@@ -2,9 +2,11 @@ import '@wisdom-utils/utils/lib/logger';
import _ from 'lodash';
import {
addGlobalUncaughtErrorHandler,
registerMicroApps,
runAfterFirstMounted,
registerMicroApps,
setDefaultMountApp,
loadMicroApp,
prefetchApps,
start,
} from 'qiankun';
import { event, store as microStore } from '@wisdom-utils/utils';
......@@ -19,213 +21,254 @@ const xss = require('xss');
const { processComponentName } = string;
// eslint-disable-next-line no-undef
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 = () => {
/* eslint-disable */
const config = window.globalConfig || {};
const application = config && config.products || [];
let products = [];
application && Array.isArray(application) && application.length > 0 && application.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: 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: event,
store: microStore
}
})
}
export const LifeCycle = {
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);
},
],
};
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 =
process.env.NODE_ENV !== 'production' ?
micorConfig.dev :
products;
const apps = entrys.map(item => {
return {
...item,
props: {
emitter: window.share.event,
baseRoot: item.name,
event: event,
store: microStore,
// eslint-
// disable-next-line no-undef
globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, {
homepage: config.homepage ? config.homepage.replace(/civweb\//, '') : config.homepage
}) : config,
//createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest,
// offGlobalStateChange: actions.offGlobalStateChange
const entrys = process.env.NODE_ENV !== 'production' ? micorConfig.dev : products;
const apps = entrys.map(item => ({
...item,
props: {
emitter: window.share.event,
baseRoot: item.name,
event,
store: microStore,
// eslint-disable-next-line prettier/prettier
globalConfig: /civweb4/.test(item.name) ? Object.assign({}, config, {homepage: config.homepage ? config.homepage.replace(/civweb\//, '') : config.homepage,}) : config,
// createStoreage.get('globalConfig'),
XMLHttpRequest: window.XMLHttpRequest,
// offGlobalStateChange: actions.offGlobalStateChange
},
loader,
}));
return apps;
};
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 => ({
...app,
loader,
})))
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);
}],
},
);
export const initMicroApps = (url) => {
if(!window.qiankunStarted) {
// /* eslint-disable */
const globalStore = store.getState().toJS();
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", {
globalConfig: globalConfig,
global: globalStore.global
globalConfig: globalConfig,
global: globalStore.globalf
});
start({
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
// 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(() => {
const microApps = application();
const micro = microApps.filter(app => (!/civweb4/.test(app.name) && url.indexOf(app.name) < 0)) ?? [];
if(window?.qiankunIsCache){
microStore.on("event:dropCache", (() => {
micorManager.map((micro) => {
micro.unmount ?? micro.unmount();
})
micorManager = [];
}));
window.qiankunStarted = true;
start(Configuration);
setTimeout(() => {
initSaveMicroApps(url);
})
runAfterFirstMounted(() => {
prefetchApps(micro);
Logger.info('[MainApp] first app mounted');
});
// eslint-disable-next-line no-use-before-define
// defaultApp();
addGlobalUncaughtErrorHandler(event => {
});
addGlobalUncaughtErrorHandler(event => {
console.log(event);
});
});
} else {
window.qiankunStarted = true;
registerMicroApps(microApps, LifeCycle);
start(Configuration);
addGlobalUncaughtErrorHandler(event => {
console.log(event);
});
}
}
};
export const defaultApp = (setUrl) => {
const globalStore = store.getState().toJS();
// eslint-disable-next-line no-undef
const config = window.globalConfig;
// const flatMenu = globalStore.global.flatMenu;
// const current = flatMenu.find(item => item.name === '首页');
// config.homepage = current.path;
if (config && config.token) {
let url = !config.home ?
((config.homepage === '' || _.isNull(config.homepage)) ? `/civbase/civweb4`: (`/civbase/${config.homepage.replace(/^\//, '')}`)) : `/civbase/${config.homepage.replace(/^\//, '')}`;
initMicroApps(setUrl || url);
setDefaultMountApp(setUrl || url);
micorManager = [];
window.share.event.emit('visible', setUrl || url);
}
};
......
......@@ -58,7 +58,7 @@ const LoginTemplate = {
export default (props) => {
const {location} = props.history;
useEffect(() => {
if(location.state && location.state.reload) {
if(location.state && location.state.reload && !window.qiankunIsCache) {
AppInitState();
}
}, []);
......
......@@ -368,20 +368,16 @@ class Login {
const homeType = config.productType || 'civweb4';
// 产品类型和首页路径同时有才行
// eslint-disable-next-line prettier/prettier
const homepage = params.getParams('homepage')
? params.getParams('homepage')
: homeType && config.homepage
? `${homeType}/${params.getParams('homepage') || config.homepage}`
: '';
const homepage = params.getParams('homepage') ? params.getParams('homepage') : homeType && config.homepage ? `${homeType}/${params.getParams('homepage') || config.homepage}` : '';
window.qiankunIsCache = config.isCache || false;
self.globalConfig = Object.assign(self.globalConfig, config, {
theme: self.globalConfig.theme,
menu: self.globalConfig.menu,
style: self.globalConfig.style,
homepage: homepage || '',
products: self.globalConfig.products,
// mapsettings: config.mapsettings
});
self.updateConfig && self.updateConfig(self.globalConfig);
self.getProjectItems().then(res => {
window.subSysCfg = {};
......
const pkg = require('../package.json');
window.arcgisAssetsPath = `${ window.location.origin}/${pkg.name.toLocaleLowerCase()}`;
\ No newline at end of file
window.arcgisAssetsPath = `${window.location.origin}/${pkg.name.toLocaleLowerCase()}`;
......@@ -167,7 +167,6 @@ export const AppInitState = () => {
window[products[item]].unmount &&
window[products[item]].unmount({ store });
});
initMicroApps();
}
// eslint-disable-next-line no-new
// 增加免登判定
......@@ -189,11 +188,11 @@ export const AppInitState = () => {
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() && window.globalConfig && window.globalConfig.token)) &&
// eslint-disable-next-line no-use-before-define
initMicroApps(loader, store);
})();
// (async () => {
// (await (getToken() && window.globalConfig && window.globalConfig.token)) &&
// // eslint-disable-next-line no-use-before-define
// initMicroApps(loader, store);
// })();
},
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