Commit 051fd8c0 authored by 张烨's avatar 张烨

feat: add login authority

parent ac33f5ff
{
"compilerOptions": {
"jsx": "react",
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": [
"node_modules"
]
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import check from './CheckPermissions';
const Authorized = ({
children,
authority,
authority, // 当前组件渲染需要的权限
noMatch = (
<Result
status="403"
......
......@@ -3,6 +3,9 @@ import { Helmet } from 'react-helmet';
import { renderRoutes } from 'react-router-config';
import { BrowserRouter as Router, Switch } from 'react-router-dom';
import config from '../../routes/config';
import Authozed from '@/utils/authority';
import UserLogin from '@/pages/user/login';
import UserLayout from '@/layouts/UserLayout';
export default function App() {
return (
......@@ -10,9 +13,18 @@ export default function App() {
<Helmet titleTemplate="%s - 运维平台" defaultTitle="运维平台">
<meta name="description" content="运维平台" />
</Helmet>
<Authozed
noMatch={
<UserLayout>
<UserLogin />
</UserLayout>
}
authority="login"
>
<Router basename={process.env.PUBLIC_PATH || 'reactOMS'}>
<Switch>{renderRoutes(config.routes)}</Switch>
</Router>
</Authozed>
</>
);
}
......@@ -17,6 +17,7 @@ const UserLayout = props => {
route = {
routes: [],
},
children,
} = props;
// const { formatMessage } = useIntl();
const { breadcrumb } = getMenuData(route.routes);
......@@ -46,7 +47,7 @@ const UserLayout = props => {
{/* Ant Design 是西湖区最具影响力的 Web 设计规范 */}
</div>
</div>
{renderRoutes(route.routes)}
{children || renderRoutes(route.routes)}
</div>
<DefaultFooter
copyright={`${new Date().getFullYear()} 熊猫智慧水务技术委员会出品`}
......
import React, { useState } from 'react';
import { Alert, Checkbox } from 'antd';
import { login } from '../../../services/user/api';
import { USER_MODE } from '../../../utils/constants';
import { login } from '@/services/user/api';
import { USER_MODE } from '@/utils/constants';
import LoginForm from './components/Login';
import styles from './style.less';
import { setAuthority } from '@/utils/authority';
const { UserName, Password, Submit } = LoginForm;
const LoginMessage = ({ content }) => (
......@@ -33,9 +33,11 @@ const Login = props => {
const { userMode } = result;
localStorage.setItem('userMode', userMode);
if (userMode === USER_MODE.ADMIN || userMode === USER_MODE.SUPER) {
setAuthority(['login', USER_MODE.ADMIN, USER_MODE.SUPER]);
window.location.href = '/dbm/dbInit/';
}
if (userMode === USER_MODE.COMMON) {
setAuthority(['login', USER_MODE.COMMON]);
window.location.href = '/ou/orgList/';
}
} else {
......
export default (...routerProps) =>
new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 1500);
}).then(() => {});
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