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

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

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