Commit 9b121196 authored by 邓晓峰's avatar 邓晓峰

fix: 修复退出登录子应用卸载

parent cffd4b71
Pipeline #48024 skipped with stages
......@@ -25,7 +25,7 @@ import {
AMAP_VIEW,
PD_VIEW,
} from './constants';
import { store } from '@wisdom-utils/utils';
export function getConfig(data) {
return {
type: GET_CONFIG,
......@@ -222,6 +222,17 @@ export function logout(data) {
// eslint-disable-next-line no-undef,no-restricted-globals
createStoreage.remove(`__PANDA_STORE__MICRO_${location.hostname}`);
localStorage.removeItem('JmReport-Access-Token');
const products = (window.globalConfig.products || []).map(item => {
if (item.PackageName === 'civweb4') {
return 'web4_console'
}
return `${item.PackageName}-main`;
});
Object.keys(products).forEach(item => {
window[products[item]] && window[products[item]] && window[products[item]].unmount && window[products[item]].unmount({ store: store });
});
return {
type: LOGINOUT,
data: {
......
......@@ -106,8 +106,7 @@ export const initGlobalConfig = () => {
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data =>
store.dispatch(actionCreators.getConfig(data)),
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
......@@ -122,17 +121,10 @@ export const initGlobalConfig = () => {
true,
);
}
// eslint-disable-next-line no-shadow
}
return res;
})
// eslint-disable-next-line no-shadow
.then(res => {
// eslint-disable-next-line no-use-before-define
// initSensorType();
// eslint-disable-next-line no-use-before-define
// initIsMock();
render({ appContent: '', loading: true });
})
.catch(error => {
......
import React from 'react';
import Cookies from 'js-cookie';
import { connect } from 'react-redux';
import { Redirect } from '@wisdom-utils/runtime';
import { Redirect, history } from '@wisdom-utils/runtime';
import { PageLoading } from '@ant-design/pro-layout';
import _ from 'lodash';
import { stringify } from 'querystring';
import { store, helpers } from '@wisdom-utils/utils';
class SecurityLayout extends React.Component {
state = {
......@@ -18,8 +19,9 @@ class SecurityLayout extends React.Component {
}
componentWillReceiveProps(nextProps) {
debugger
const products = (this.props.global.products || []).map(item => {
if(item.PackageName === 'civweb4') {
if (item.PackageName === 'civweb4') {
return 'web4_console'
}
return `${item.PackageName}-main`;
......@@ -30,35 +32,36 @@ class SecurityLayout extends React.Component {
const nextPathname = nextProps.location.pathname;
const nextArgv = nextPathname.split('/');
console.log(argv[2], nextArgv[2])
if(argv[2] !== nextArgv[2]) {
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: store });
});
}
if(this.props.location.pathname !== nextProps.location.pathname) {
store.set('event:globalConfig', {globalConfig: nextProps.global});
if (this.props.location.pathname !== nextProps.location.pathname) {
store.set('event:globalConfig', { globalConfig: nextProps.global });
}
}
render() {
const { isReady } = this.state;
const { children, global, loading } = this.props;
const isLogin = Cookies.get('token') !== null && global.token !== null;
// const queryString = stringify({
// redirect: window.location.href,
// });
if (!Cookies.get('token')) {
if (!isLogin && window.location.pathname !== '/civbase/user/login') {
const { query = {}, search, pathname } = history.location;
const { redirect } = query;
const queryString = stringify({
redirect: pathname + search,
});
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || Cookies.get('city');
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
// event.emit(?'event:initConfig');
let { generateType } = global;
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
generateType = !_.isNull(generateType) && !_.isUndefined(generateType) && generateType !== 'undefined' ? `&generateType=${generateType}` : '';
return (
<Redirect
to={`/user/login?client=${client}${generateType}`}
to={`/user/login?client=${client}${generateType}&${queryString}`}
/>
);
}
......
import React from 'react';
import React, { useEffect } from 'react';
import BaseLogin from './template/baseLogin';
import NewYear from './template/newYear';
import InfoLogin from './template/infoLogin';
import Yulin from './template/yulin';
import { getParams } from '@wisdom-utils/utils/lib/helpers/params';
// import { useParams } from '@wisdom-utils/runtime';
import { initGlobalConfig } from '../../../initConfig';
const LoginTemplate = {
'新春 - 智联.html': NewYear,
......@@ -16,9 +18,10 @@ const LoginTemplate = {
};
/* eslint-disable */
export default (props) => {
// React.useEffect(() => {
// initGlobalConfig();
// }, [props.location]);
const redirect = getParams('redirect');
useEffect(() => {
initGlobalConfig();
}, [redirect]);
const template = window.globalConfig && window.globalConfig.loginTemplate;
const RenderComponent = LoginTemplate[template] ? LoginTemplate[template]: LoginTemplate['default'];
return <RenderComponent {...props}/>
......
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