Commit abbd2d83 authored by 崔佳豪's avatar 崔佳豪

fix: 清除重复监听loginSuccess后,无法切换站点问题

parent 6b81c4d5
......@@ -14,6 +14,8 @@ import { appService } from '../api';
import CitySelector from '../components/CitySelector';
import Login from '../pages/user/login/login';
import styles from './UserLayout.less';
import { initMicroApps } from '@/micro';
const { Link } = Anchor;
......@@ -343,6 +345,8 @@ class Site {
// eslint-disable-next-line no-unused-expressions
self.props.updateCurrentIndex && self.props.updateCurrentIndex(0);
initMicroApps();
// 切换站点后,重置掉三级菜单
const homeType = self.globalConfig.homeType || 'civweb4';
const homePath =
......
......@@ -58,11 +58,14 @@ const renderIndustries = (config, callback) =>
}
});
let loginAction = null;
// let loginAction = null;
const BootPage = props => {
const [loadding, setLoadding] = useState(false);
const [hasRole, setHasRole] = useState(false);
const [scale, setScale] = useState(1);
const [loginAction, setAction] = useState(
() => new LoginAction(props),
);
const history = useHistory();
useDocumentTitle(
{ title: defaultSetting.title, id: '', pageName: '行业切换' },
......@@ -80,18 +83,6 @@ const BootPage = props => {
props.instance && props.instance.updateConfig(config);
// props.instance && props.instance.getUserInfoAndConfig('', true, type);
loginAction && loginAction.getUserInfoAndConfig('', true, type);
// eslint-disable-next-line no-shadow
// loginAction.events.on('toggleIndustry', event => {
// setLoadding(false);
// // props.history.push(`/?client=${props.global.client}`);
// debugger
// initMicroApps();
// // 加载首页
// history.push(props.global.homepage ?? `/?client=${props.global.client}`);
// window.share.event.emit('triggerMicro', props.global);
// props.updateCurrentIndex(0);
// // window.location.reload();
// });
}, []);
useEffect(() => {
// eslint-disable-next-line no-use-before-define
......@@ -106,22 +97,20 @@ const BootPage = props => {
};
useEffect(() => {
window.addEventListener('resize', handleResize);
loginAction = new LoginAction(props);
loginAction.events.on('toggleIndustry', event => {
const handleToggleIndustry = event => {
setLoadding(false);
props.history.push(`/?client=${props.global.client}`);
initMicroApps();
// 加载首页
// history.push(props.global.homepage ?? `/?client=${props.global.client}`);
window.share.event.emit('triggerMicro', props.global);
props.updateCurrentIndex(0);
// window.location.reload();
});
}
loginAction.events.on('toggleIndustry', handleToggleIndustry);
return () => {
window.removeEventListener('resize', handleResize);
loginAction.events.removeAllListeners('toggleIndustry');
loginAction.events.removeListener('toggleIndustry', handleToggleIndustry);
};
});
}, []);
const renderIndustr = useMemo(
() => renderIndustries(props.global, handlePage),
[],
......
......@@ -53,12 +53,10 @@
width: 2px;
}
.bootPageUl {
// display: flex;
// width: 1280px;
// flex-wrap: wrap;
// justify-content: center;
display: grid;
grid-template-columns: repeat(4, 25%);
display: flex;
width: 1280px;
flex-wrap: wrap;
justify-content: center;
list-style: none;
transition: all .5s ease-out;
overflow: hidden;
......
......@@ -857,7 +857,6 @@ class Login {
}
login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password) {
this.events.removeAllListeners('loginError');
const self = this;
if(window.globalConfig && window.globalConfig.hasGateWay) {
usr = userPhone ? userPhone: usr;
......
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