|
@@ -4,12 +4,12 @@ import apiObj from '@api/index';
|
|
|
import { add } from '@reducers/userInfo'
|
|
|
|
|
|
const {post,api} = apiObj;
|
|
|
-function Login() {
|
|
|
+function Login({history}) {
|
|
|
/*useEffect(() => {
|
|
|
login();
|
|
|
});*/
|
|
|
//const dispatch = useDispatch();
|
|
|
- function login(){
|
|
|
+ function getLogin(){
|
|
|
post(api.login,{
|
|
|
"password": "a123456",
|
|
|
"username": "admin"
|
|
@@ -19,11 +19,12 @@ function Login() {
|
|
|
const data = res.data.data;
|
|
|
//dispatch(add(res.data.data))
|
|
|
localStorage.setItem('token',data.token);
|
|
|
+ history.push('/manage')
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
return (
|
|
|
- <button onClick={login}>登录</button>
|
|
|
+ <button onClick={getLogin}>登录</button>
|
|
|
)
|
|
|
}
|
|
|
|