Commit f5dcfd8f authored by 邓晓峰's avatar 邓晓峰

fix: 修复三级菜单高亮选中

parent aef6f532
Pipeline #35951 passed with stages
in 30 minutes 4 seconds
......@@ -12,22 +12,15 @@ import 'sanitize.css/sanitize.css';
import React from 'react';
import ReactDOM from 'react-dom';
import {
Button, ConfigProvider,
message,
notification,
} from 'antd';
import { Button, ConfigProvider, message, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable';
import Immutable from 'immutable';
import {
params,
Storeage,
} from 'kit_utils';
import { params, Storeage } from 'kit_utils';
import { Provider } from 'react-redux';
import { useIntl } from '@/locales/localeExports';
import { ErrorBoundary } from '@ant-design/pro-utils';
import { history } from '@wisdom-utils/runtime';
import ErrorBoundary from './components/ErrorBoundary';
import { useIntl } from '@/locales/localeExports';
// import { ErrorBoundary } from '@ant-design/pro-utils';
import defaultSettings from '../config/defaultSetting';
// import themePluginConfig from '../config/themePluginConfig';
......@@ -40,10 +33,7 @@ import { actionCreators } from './containers/App/store';
import { LocaleContainer } from './locales/locale';
import { initMicroApps } from './micro';
import Login from './pages/user/login/login';
import {
getToken,
isString,
} from './utils/utils';
import { getToken, isString } from './utils/utils';
import './utils/event';
import Cookies from 'js-cookie';
const isHttps = document.location.protocol === 'https:';
......@@ -62,13 +52,13 @@ const render = () => {
<Provider store={store}>
<ConnectedRouter history={history}>
<LocaleContainer>
<ErrorBoundary>
<Container>
<ConfigProvider prefixCls="panda-console-base">
<ConfigProvider prefixCls="panda-console-base">
<ErrorBoundary>
<Container>
<App />
</ConfigProvider>
</Container>
</ErrorBoundary>
</Container>
</ErrorBoundary>
</ConfigProvider>
</LocaleContainer>
</ConnectedRouter>
</Provider>,
......@@ -130,7 +120,9 @@ const initGlobalConfig = () => {
});
// eslint-disable-next-line react-hooks/rules-of-hooks
appService
.queryConfig({ client: params.getParams('client') || Cookies.get('city') || 'city' })
.queryConfig({
client: params.getParams('client') || Cookies.get('city') || 'city',
})
.then(res => {
if (res) {
const data = res;
......@@ -158,7 +150,7 @@ const initGlobalConfig = () => {
updateConfig: data =>
store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout())
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
......@@ -232,7 +224,6 @@ window.share &&
initMicroApps(loader, store);
});
if (pwa) {
// const appPWA = window.i18n.getI18n('app');
window.addEventListener('sw.offline', () => {
......
import React from 'react';
import { Result } from 'antd';
class ErrorBoundary extends React.Component {
state = { hasError: false, errorInfo: '' };
static getDerivedStateFromError(error) {
return { hasError: true, errorInfo: error.message };
}
componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
// eslint-disable-next-line no-console
console.log(error, errorInfo);
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return (
<Result
status="error"
title="Something went wrong."
extra={this.state.errorInfo}
/>
);
}
return this.props.children;
}
}
export default ErrorBoundary;
......@@ -352,8 +352,11 @@ const BasicLayout = props => {
useEffect(() => {
const routes = currentRoutes.routes[selectIndex];
if(routes) {
const route = routes && routes.routes.find(item => item.path === decodeURI(window.location.pathname.replace('/civbase', '')));
setTabActiveKey(route.path)
if( routes && routes.routes) {
const route = routes && routes.routes && routes.routes.find(item => item.path === decodeURI(window.location.pathname.replace('/civbase', '')));
setTabActiveKey(route.path)
}
}
}, [props.location]);
// window.share.event.on('event:history', params => {
......@@ -614,7 +617,7 @@ const BasicLayout = props => {
item.routes ? renderChildrenMenu(item) : (
<>
{
item.icon ? item.icon: item.extData && /.svg/.test(item.extData.icon) ? <ReactSVG src={item.extData.icon} style={{width: '18px', height: '18px'}}/>:item.extData && <img src={item.extData.icon} style={{width: '18px', height: '18px'}}/>
item.icon ? item.icon: item.extData && /.svg/.test(item.extData.icon) ? <ReactSVG src={item.extData.icon} beforeInjection={svg => console.log(svg)} style={{width: '18px', height: '18px'}}/>:item.extData && <img src={item.extData.icon} style={{width: '18px', height: '18px'}}/>
}
<span className={layoutStyles['menu-item-name']}>{item.name}</span>
{
......
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