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

fix:云平台登录逻辑修改

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