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

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

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