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'; ...@@ -12,22 +12,15 @@ import 'sanitize.css/sanitize.css';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { import { Button, ConfigProvider, message, notification } from 'antd';
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';
import { import { params, Storeage } from 'kit_utils';
params,
Storeage,
} from 'kit_utils';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { useIntl } from '@/locales/localeExports';
import { ErrorBoundary } from '@ant-design/pro-utils';
import { history } from '@wisdom-utils/runtime'; 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 defaultSettings from '../config/defaultSetting';
// import themePluginConfig from '../config/themePluginConfig'; // import themePluginConfig from '../config/themePluginConfig';
...@@ -40,10 +33,7 @@ import { actionCreators } from './containers/App/store'; ...@@ -40,10 +33,7 @@ import { actionCreators } from './containers/App/store';
import { LocaleContainer } from './locales/locale'; import { LocaleContainer } from './locales/locale';
import { initMicroApps } from './micro'; import { initMicroApps } from './micro';
import Login from './pages/user/login/login'; import Login from './pages/user/login/login';
import { import { getToken, isString } from './utils/utils';
getToken,
isString,
} from './utils/utils';
import './utils/event'; import './utils/event';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
const isHttps = document.location.protocol === 'https:'; const isHttps = document.location.protocol === 'https:';
...@@ -62,13 +52,13 @@ const render = () => { ...@@ -62,13 +52,13 @@ const render = () => {
<Provider store={store}> <Provider store={store}>
<ConnectedRouter history={history}> <ConnectedRouter history={history}>
<LocaleContainer> <LocaleContainer>
<ConfigProvider prefixCls="panda-console-base">
<ErrorBoundary> <ErrorBoundary>
<Container> <Container>
<ConfigProvider prefixCls="panda-console-base">
<App /> <App />
</ConfigProvider>
</Container> </Container>
</ErrorBoundary> </ErrorBoundary>
</ConfigProvider>
</LocaleContainer> </LocaleContainer>
</ConnectedRouter> </ConnectedRouter>
</Provider>, </Provider>,
...@@ -130,7 +120,9 @@ const initGlobalConfig = () => { ...@@ -130,7 +120,9 @@ const initGlobalConfig = () => {
}); });
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
appService appService
.queryConfig({ client: params.getParams('client') || Cookies.get('city') || 'city' }) .queryConfig({
client: params.getParams('client') || Cookies.get('city') || 'city',
})
.then(res => { .then(res => {
if (res) { if (res) {
const data = res; const data = res;
...@@ -158,7 +150,7 @@ const initGlobalConfig = () => { ...@@ -158,7 +150,7 @@ const initGlobalConfig = () => {
updateConfig: data => updateConfig: data =>
store.dispatch(actionCreators.getConfig(data)), store.dispatch(actionCreators.getConfig(data)),
isInit: false, isInit: false,
logout: () => store.dispatch(actionCreators.logout()) logout: () => store.dispatch(actionCreators.logout()),
}, },
() => { () => {
(async () => { (async () => {
...@@ -232,7 +224,6 @@ window.share && ...@@ -232,7 +224,6 @@ window.share &&
initMicroApps(loader, store); initMicroApps(loader, store);
}); });
if (pwa) { if (pwa) {
// const appPWA = window.i18n.getI18n('app'); // const appPWA = window.i18n.getI18n('app');
window.addEventListener('sw.offline', () => { 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,9 +352,12 @@ const BasicLayout = props => { ...@@ -352,9 +352,12 @@ const BasicLayout = props => {
useEffect(() => { useEffect(() => {
const routes = currentRoutes.routes[selectIndex]; const routes = currentRoutes.routes[selectIndex];
if(routes) { if(routes) {
const route = routes && routes.routes.find(item => item.path === decodeURI(window.location.pathname.replace('/civbase', ''))); if( routes && routes.routes) {
const route = routes && routes.routes && routes.routes.find(item => item.path === decodeURI(window.location.pathname.replace('/civbase', '')));
setTabActiveKey(route.path) setTabActiveKey(route.path)
} }
}
}, [props.location]); }, [props.location]);
// window.share.event.on('event:history', params => { // window.share.event.on('event:history', params => {
// setTimeout(() => { // setTimeout(() => {
...@@ -614,7 +617,7 @@ const BasicLayout = props => { ...@@ -614,7 +617,7 @@ const BasicLayout = props => {
item.routes ? renderChildrenMenu(item) : ( 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> <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