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,
......
This diff is collapsed.
...@@ -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