增加登录验证
This commit is contained in:
13
src/wrappers/auth.tsx
Normal file
13
src/wrappers/auth.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import { Redirect } from 'umi';
|
||||
import { message } from 'antd';
|
||||
// 权限校验
|
||||
export default (props: any) => {
|
||||
if (localStorage.getItem('token')) {
|
||||
return <div>{props.children}</div>;
|
||||
} else {
|
||||
// 提示后跳转
|
||||
message.error('请先登录');
|
||||
return <Redirect to="/login" />;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user