Commit 317eb79c authored by 杨思琦's avatar 杨思琦

fix:云平台登录逻辑修改

parent 3df34b6e
Pipeline #89566 waiting for manual action with stages
......@@ -825,6 +825,9 @@ const mapDispatchToProps = dispatch => ({
logout() {
dispatch(actionCreators.logout());
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
});
export default connect(
mapStateToProps,
......
......@@ -64,12 +64,13 @@ class SecurityLayout extends React.Component {
const { children, global, loading } = this.props;
const tk = Cookies.get('token') || global.token;
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)
) {
if (isLogin && window.location.pathname !== `/civbase/industry` && !window.finishRender) {
if (window.globalConfig?.userInfo?.Groups && window.globalConfig?.Industry === '') {
return <Redirect to={{ pathname: `/industry`, state: { reload: true } }} exact />;
}
return <PageLoading />;
}
if (!isLogin && window.location.pathname !== '/civbase/user/login') {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || sessionStorage.getItem('client');
client = client !== 'undefined' && !_.isNull(client) && !_.isUndefined(client) ? client : 'city';
......
......@@ -278,6 +278,7 @@ export const initMicroApps = (url) => {
initSaveMicroApps(url);
start(Configuration);
runAfterFirstMounted(() => {
window.parent && window.parent.postMessage({ type: 'runAfterFirstMounted' }, '*');
event.emit('loading', false);
setTimeout(() => {
prefetchApps(micro);
......@@ -294,6 +295,11 @@ export const initMicroApps = (url) => {
setTimeout(() => {
url.indexOf('civbase/civ_base') > -1 && event.emit('loading', false)
})
runAfterFirstMounted(() => {
window.parent && window.parent.postMessage({ type: 'runAfterFirstMounted' }, '*');
event.emit('loading', false);
Logger.info('[MainApp] first app mounted');
});
addGlobalUncaughtErrorHandler(event => {
console.log(event);
});
......
......@@ -459,6 +459,7 @@ class Login {
finish(self, getIndustry) {
self.events.emit('onendLoading');
setTimeout(() => {
window.finishRender = true;
getIndustry ? self.events.emit('toggleIndustry') : self.events.emit('loginSuccess');
window.share.event = self.events;
self.callback && self.callback();
......@@ -639,6 +640,7 @@ class Login {
}
getUserInfoAndConfig(failCallback, flag, industry, toSite) {
this.updateConfig(window.globalConfig);
const { token: tk } = this.globalConfig;
const token = tk || Cookies.get('token');
const site = Cookies.get('site');
......
......@@ -276,6 +276,7 @@ class Login {
getUserInfo(param)
.then(response => {
if (response && response.code === 0) {
self.isSignIn = true;
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
self.updateConfig && self.updateConfig(self.globalConfig);
self.getUserInfoAndConfig();
......@@ -345,15 +346,21 @@ class Login {
});
}
// eslint-disable-next-line prettier/prettier
if (!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1) {
if (!flag && this.isSignIn && this.globalConfig.userInfo.Industries.length && this.globalConfig.userInfo.Industries.length > 1 && !window.qiankunStarted) {
this.createContext(this);
this.updateConfig && this.updateConfig(this.globalConfig);
this.history.push('/industry');
this.events && this.events.emit('loginIndustry');
return false;
}
// 跳转到集成登录引导页_xule_2023-08-28
if (!flag && this.isSignIn && this.globalConfig.isIntegration >= 1 && this.integratedNum >= 2) {
this.history.push('/industry');
if (
!flag &&
this.isSignIn &&
this.globalConfig.isIntegration >= 1 &&
this.integratedNum >= 2 &&
!window.qiankunStarted
) {
this.events && this.events.emit('loginIndustry');
return false;
}
this.initGateWay(token, getIndustry);
......@@ -707,6 +714,7 @@ class Login {
}
finish(self, getIndustry) {
window.finishRender = true;
getIndustry ? self.events.emit('toggleIndustry') : self.events.emit('loginSuccess');
window.share.event = self.events;
self.callback && self.callback();
......@@ -752,6 +760,7 @@ class Login {
if (transitionPage.content.length > 0) {
self.globalConfig.transitionPage = transitionPage;
self.updateConfig && self.updateConfig(self.globalConfig);
window.finishRender = true;
self.events.emit('loginHomePage');
window.share.event = self.events;
return self.callback && self.callback();
......
......@@ -84,8 +84,12 @@ const Login = forwardRef((props, _ref) => {
}, [action, action.globalConfig, props.global]);
useEffect(() => {
action.events.on('loginError', event => {
window.parent && window.parent.postMessage({ type: 'loginError', msg: event }, '*');
});
action &&
action.events.on('loginSuccess', event => {
window.parent && window.parent.postMessage({ type: 'loginSuccess' }, '*');
// http://127.0.0.1:8080/civbase/civweb4/
props.updateConfig(
Object.assign({}, window.globalConfig, {
......@@ -109,6 +113,7 @@ const Login = forwardRef((props, _ref) => {
});
return () => {
action && action.events && action.events.removeAllListeners('loginSuccess');
action && action.events && action.events.removeAllListeners('loginError');
};
}, [action, props.global.client, props.global.generateType, props.history, redirect]);
......
......@@ -86,12 +86,15 @@ const Login = forwardRef((props, _ref) => {
action.events.on('loginHomePage', () => {
props.history.push(`/homePage`);
})
// }
action.events.on('loginIndustry', () => {
props.history.push(`/industry`);
});
return () => {
action && action.events && action.events.removeAllListeners('loginSuccess');
action && action.events && action.events.removeAllListeners('loginError');
action && action.events && action.events.removeAllListeners('loginVisible');
action && action.events && action.events.removeAllListeners('loginHomePage');
action && action.events && action.events.removeAllListeners('loginIndustry');
}
}, [props.loginMode]);
......
......@@ -186,8 +186,8 @@ export const AppInitState = () => {
},
gateWayConfig,
),
// eslint-disable-next-line no-shadow
updateConfig: data => store.dispatch(actionCreators.getConfig(data)),
createContext: value => store.dispatch(actionCreators.createContext(value)),
updateConfig: value => store.dispatch(actionCreators.getConfig(value)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
......@@ -210,6 +210,9 @@ export const AppInitState = () => {
const url = `civbase/${findMenuPath([allWidgets[0]])}`;
defaultApp(url);
});
action.events.on('loginIndustry', event => {
window.history.pushState('', '', `/civbase/industry`);
});
}
return window.globalConfig.variableTheme;
}
......
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