Commit 6f787970 authored by 张烨's avatar 张烨

fix: fix登录权限路由菜单没有刷新

parent 328b6031
...@@ -17,7 +17,7 @@ import zhCN from 'antd/es/locale/zh_CN'; ...@@ -17,7 +17,7 @@ import zhCN from 'antd/es/locale/zh_CN';
import configureStore from './configureStore'; import configureStore from './configureStore';
import App from './containers/App'; import App from './containers/App';
import history from './utils/history'; import history from './utils/history';
import config from './routes/config';
const initialState = Immutable.Map(); const initialState = Immutable.Map();
const store = configureStore(initialState, history); const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('app'); const MOUNT_NODE = document.getElementById('app');
...@@ -27,7 +27,7 @@ const render = () => { ...@@ -27,7 +27,7 @@ const render = () => {
<Provider store={store}> <Provider store={store}>
<ConnectedRouter history={history}> <ConnectedRouter history={history}>
<ConfigProvider locale={zhCN}> <ConfigProvider locale={zhCN}>
<App /> <App routesConfig={config} />
</ConfigProvider> </ConfigProvider>
</ConnectedRouter> </ConnectedRouter>
</Provider>, </Provider>,
......
...@@ -3,12 +3,12 @@ import { Helmet } from 'react-helmet'; ...@@ -3,12 +3,12 @@ import { Helmet } from 'react-helmet';
import { renderRoutes } from 'react-router-config'; import { renderRoutes } from 'react-router-config';
import { BrowserRouter as Router, Switch } from 'react-router-dom'; import { BrowserRouter as Router, Switch } from 'react-router-dom';
import { appConnector } from './store'; import { appConnector } from './store';
import config from '../../routes/config';
import Authozed from '@/utils/authority'; import Authozed from '@/utils/authority';
import UserLogin from '@/pages/user/login'; import UserLogin from '@/pages/user/login';
import UserLayout from '@/layouts/UserLayout'; import UserLayout from '@/layouts/UserLayout';
import { AUTHORITY, BASENAME } from '@/utils/constants'; import { AUTHORITY, BASENAME } from '@/utils/constants';
export default appConnector(function App(props) { export default appConnector(function App(props) {
const { routesConfig } = props;
return ( return (
<> <>
<Helmet titleTemplate="%s - 运维平台" defaultTitle="运维平台"> <Helmet titleTemplate="%s - 运维平台" defaultTitle="运维平台">
...@@ -23,7 +23,7 @@ export default appConnector(function App(props) { ...@@ -23,7 +23,7 @@ export default appConnector(function App(props) {
} }
authority={[AUTHORITY.LOGIN]} authority={[AUTHORITY.LOGIN]}
> >
<Switch>{renderRoutes(config.routes)}</Switch> <Switch>{renderRoutes(routesConfig.routes)}</Switch>
</Authozed> </Authozed>
</Router> </Router>
</> </>
......
...@@ -7,6 +7,7 @@ import ProLayout, { DefaultFooter } from '@ant-design/pro-layout'; ...@@ -7,6 +7,7 @@ import ProLayout, { DefaultFooter } from '@ant-design/pro-layout';
import logo from '../assets/images/logo/panda-logo.svg'; import logo from '../assets/images/logo/panda-logo.svg';
import RightContent from '../components/GlobalHeader/RightContent'; import RightContent from '../components/GlobalHeader/RightContent';
import { BASENAME } from '@/utils/constants';
// const noMatch = ( // const noMatch = (
// <Result // <Result
...@@ -27,15 +28,16 @@ const defaultFooterDom = ( ...@@ -27,15 +28,16 @@ const defaultFooterDom = (
const BasicLayout = props => { const BasicLayout = props => {
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
const [pathname, setPathname] = useState('/welcome'); const [pathname, setPathname] = useState(`/${BASENAME}`);
const filterMenu = menuRoutes => const filterMenu = menuRoutes =>
menuRoutes menuRoutes
.map(route => { .map(route => {
if (route.routes) route.routes = filterMenu(route.routes); const routeCopy = { ...route };
return route.hideMenu || if (routeCopy.routes) routeCopy.routes = filterMenu(routeCopy.routes);
(route.authority && !check(route.authority, true, false)) return routeCopy.hideMenu ||
(routeCopy.authority && !check(routeCopy.authority, true, false))
? null ? null
: route; : routeCopy;
}) })
.filter(Boolean); .filter(Boolean);
const handleMenuCollapse = () => {}; // get children authority const handleMenuCollapse = () => {}; // get children authority
......
...@@ -48,10 +48,13 @@ const Login = props => { ...@@ -48,10 +48,13 @@ const Login = props => {
history.push(`/dbm/dbInit/`); history.push(`/dbm/dbInit/`);
} }
if (userMode === USER_MODE.COMMON) { if (userMode === USER_MODE.COMMON) {
const authority = [AUTHORITY.LOGIN, AUTHORITY.COMMON]; // const authority = [AUTHORITY.LOGIN, AUTHORITY.COMMON];
setAuthority(authority); // setAuthority(authority);
setAuth(authority); // setAuth(authority);
history.push(`/ou/orgList/`); // history.push(`/ou/orgList/`);
notification.warning({
message: msg || '没有权限!',
});
} }
} else { } else {
notification.warning({ notification.warning({
...@@ -60,7 +63,7 @@ const Login = props => { ...@@ -60,7 +63,7 @@ const Login = props => {
} }
setLoading(false); setLoading(false);
}) })
.then(e => { .catch(e => {
setLoading(false); setLoading(false);
notification.error({ notification.error({
message: e.message || '没有权限!', message: e.message || '没有权限!',
......
...@@ -33,7 +33,7 @@ const iconStyle = { verticalAlign: '0.125em' }; ...@@ -33,7 +33,7 @@ const iconStyle = { verticalAlign: '0.125em' };
const superAuthority = [USER_MODE.SUPER]; const superAuthority = [USER_MODE.SUPER];
const adminAuthority = [...superAuthority, USER_MODE.ADMIN]; const adminAuthority = [...superAuthority, USER_MODE.ADMIN];
const commonAuthority = [...adminAuthority, USER_MODE.COMMON]; // const commonAuthority = [...adminAuthority, USER_MODE.COMMON];
export default { export default {
routes: [ routes: [
...@@ -102,7 +102,7 @@ export default { ...@@ -102,7 +102,7 @@ export default {
path: '/userCenter', path: '/userCenter',
name: '用户中心', name: '用户中心',
component: BlankLayout, component: BlankLayout,
authority: commonAuthority, authority: adminAuthority,
icon: <UsergroupAddOutlined style={iconStyle} />, icon: <UsergroupAddOutlined style={iconStyle} />,
routes: [ routes: [
{ {
...@@ -133,7 +133,7 @@ export default { ...@@ -133,7 +133,7 @@ export default {
component: BlankLayout, component: BlankLayout,
name: '平台中心', name: '平台中心',
icon: <SettingOutlined style={iconStyle} />, icon: <SettingOutlined style={iconStyle} />,
authority: commonAuthority, authority: adminAuthority,
routes: [ routes: [
{ {
path: '/platformCenter/gis', path: '/platformCenter/gis',
...@@ -188,7 +188,7 @@ export default { ...@@ -188,7 +188,7 @@ export default {
component: BlankLayout, component: BlankLayout,
name: '应用中心', name: '应用中心',
icon: <HomeOutlined style={iconStyle} />, icon: <HomeOutlined style={iconStyle} />,
authority: commonAuthority, authority: adminAuthority,
routes: [ routes: [
{ {
path: '/productCenter/web', path: '/productCenter/web',
...@@ -212,7 +212,7 @@ export default { ...@@ -212,7 +212,7 @@ export default {
component: BlankLayout, component: BlankLayout,
name: '系统日志', name: '系统日志',
icon: <CopyOutlined style={iconStyle} />, icon: <CopyOutlined style={iconStyle} />,
authority: commonAuthority, authority: adminAuthority,
routes: [ routes: [
{ {
path: '/log/common', path: '/log/common',
......
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