Commit 3bcbac2d authored by 邓晓峰's avatar 邓晓峰

fix: 修复登录BUG

parent b72c6572
Pipeline #39771 passed with stages
in 14 minutes 22 seconds
...@@ -14,6 +14,7 @@ import 'sanitize.css/sanitize.css'; ...@@ -14,6 +14,7 @@ import 'sanitize.css/sanitize.css';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { event } from 'microser-data'; import { event } from 'microser-data';
import _ from 'lodash';
import { Button, ConfigProvider, message, notification } from 'antd'; import { Button, ConfigProvider, message, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable'; import { ConnectedRouter } from 'connected-react-router/immutable';
import Immutable from 'immutable'; import Immutable from 'immutable';
...@@ -117,9 +118,10 @@ const initGlobalConfig = () => { ...@@ -117,9 +118,10 @@ const initGlobalConfig = () => {
} }
}); });
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
const client = !_.isNull(params.getParams('client')) ? params.getParams('client') : Cookies.get('city') ? Cookies.get('city'): 'city';
appService appService
.queryConfig({ .queryConfig({
client: Cookies.get('city') || params.getParams('client'), client: client,
}) })
.then(res => { .then(res => {
if (res) { if (res) {
...@@ -128,7 +130,7 @@ const initGlobalConfig = () => { ...@@ -128,7 +130,7 @@ const initGlobalConfig = () => {
if (!data.client) { if (!data.client) {
data.client = params.getParams('client') || 'city'; data.client = params.getParams('client') || 'city';
} }
Cookies.set('city', data.client); // Cookies.set('city', data.client);
store.dispatch( store.dispatch(
actionCreators.getConfig( actionCreators.getConfig(
Object.assign({}, window.globalConfig, data), Object.assign({}, window.globalConfig, data),
......
...@@ -7,6 +7,7 @@ import styles from './min.less'; ...@@ -7,6 +7,7 @@ import styles from './min.less';
const Categories = props => { const Categories = props => {
const [currentIndex, setCurrentIndex] = useState(props.currentMenuIndex); const [currentIndex, setCurrentIndex] = useState(props.currentMenuIndex);
const selectCategories = (event, index) => { const selectCategories = (event, index) => {
debugger
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
event.nativeEvent.stopImmediatePropagation(); event.nativeEvent.stopImmediatePropagation();
...@@ -18,7 +19,7 @@ const Categories = props => { ...@@ -18,7 +19,7 @@ const Categories = props => {
<div className={classNames(styles['menu-categories'], { <div className={classNames(styles['menu-categories'], {
[styles['min-cateorites']]: props.mode [styles['min-cateorites']]: props.mode
})}> })}>
{(props.data || []).map((item, index) => { {(props.data || []).filter(item => !item.hideInMenu).map((item, index) => {
const categorieCls = classNames( const categorieCls = classNames(
styles['categorie-name'], styles['categorie-name'],
styles.btn, styles.btn,
...@@ -35,7 +36,8 @@ const Categories = props => { ...@@ -35,7 +36,8 @@ const Categories = props => {
<span>{item.extData.label}</span> <span>{item.extData.label}</span>
</div> </div>
); );
})} })
}
</div> </div>
); );
}; };
......
...@@ -268,7 +268,10 @@ const BasicLayout = props => { ...@@ -268,7 +268,10 @@ const BasicLayout = props => {
const basename = getBaseName(); const basename = getBaseName();
const history = useHistory(); const history = useHistory();
let currentRoutes = props.route.routes[props.currentMenuIndex] // 处理隐藏菜单
let currentRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex];
//props.currentMenuIndex
useEffect(() => { useEffect(() => {
const initSelectRoute = findPathByLeafId( const initSelectRoute = findPathByLeafId(
`${props.location && props.location.pathname || ''}`, `${props.location && props.location.pathname || ''}`,
...@@ -305,6 +308,10 @@ const BasicLayout = props => { ...@@ -305,6 +308,10 @@ const BasicLayout = props => {
]) ])
} }
}, []); }, []);
useEffect(() => {
console.log(props.route.routes);
}, [props.currentMenuIndex]);
window.share && window.share.event && window.share.event.on('event:updateCurrentChildrenRoutes', ({currentPath, currentRoute, selectedIndex}) => { window.share && window.share.event && window.share.event.on('event:updateCurrentChildrenRoutes', ({currentPath, currentRoute, selectedIndex}) => {
currentRoute && currentRoute.parent && currentRoute.parent.routes ? setChildrenRoutes(currentRoute.parent.routes): !currentRoute.parent ? setChildrenRoutes(currentRoute.routes): setChildrenRoutes([currentRoute]); currentRoute && currentRoute.parent && currentRoute.parent.routes ? setChildrenRoutes(currentRoute.parent.routes): !currentRoute.parent ? setChildrenRoutes(currentRoute.routes): setChildrenRoutes([currentRoute]);
setSelectIndex(selectedIndex); setSelectIndex(selectedIndex);
...@@ -419,6 +426,7 @@ const BasicLayout = props => { ...@@ -419,6 +426,7 @@ const BasicLayout = props => {
} }
const handleUpdateCurrentIndex = index => { const handleUpdateCurrentIndex = index => {
debugger
setSelectIndex(-1) setSelectIndex(-1)
props.updateCurrentIndex(index); props.updateCurrentIndex(index);
window.share && window.share.event.emit('trigger:updateMenuIndex', index); window.share && window.share.event.emit('trigger:updateMenuIndex', index);
......
...@@ -754,7 +754,10 @@ class Login { ...@@ -754,7 +754,10 @@ class Login {
if(response.access_token!== "") { if(response.access_token!== "") {
self.globalConfig.access_token = response.access_token; self.globalConfig.access_token = response.access_token;
localStorage.setItem('access_token', response.access_token); localStorage.setItem('access_token', response.access_token);
Cookies.set('city', self.globalConfig.client) Cookies.set('city', self.globalConfig.client, {
expires: exp / (24 * 60 * 60 * 1000),
path: '/',
})
} }
if (isRememberPWD) { if (isRememberPWD) {
Cookies.set('city', self.globalConfig.client, { Cookies.set('city', self.globalConfig.client, {
......
...@@ -35,7 +35,7 @@ export const dyRoutes = routes => { ...@@ -35,7 +35,7 @@ export const dyRoutes = routes => {
{ {
path: '/commonmenu', path: '/commonmenu',
component: CommonMenu, component: CommonMenu,
name: 'commonmenu' name: '菜单收藏'
}, },
{ {
path: '/404', path: '/404',
......
...@@ -102,7 +102,8 @@ const generRotes = (widgets, parent, level = 0) => { ...@@ -102,7 +102,8 @@ const generRotes = (widgets, parent, level = 0) => {
href: url, href: url,
target: isURL(url) ? '_blank' : '', target: isURL(url) ? '_blank' : '',
key: guid('panda'), key: guid('panda'),
hideInMenu: l > 3 ? true: item.hideInMenu || false, hideInMenu: item.label === '系统菜单组' ? true: item.hideInMenu,
//l > 3 ? true: item.hideInMenu || false,
alias: item.product || DEFAULT_APPLICATION, alias: item.product || DEFAULT_APPLICATION,
extData: { extData: {
...item, ...item,
......
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