登录改为表单
parent
e3c0fd2659
commit
420b6155ae
|
@ -1,4 +1,4 @@
|
|||
import React, { FC } from 'react';
|
||||
import React, {FC, useEffect} from 'react';
|
||||
import { Button } from 'antd';
|
||||
import {useAppSelector} from "../models/hooks";
|
||||
import {getToken, store} from "../models/store";
|
||||
|
@ -8,8 +8,12 @@ function HomeView() {
|
|||
const token = useAppSelector(getToken);
|
||||
const navigate = useNavigate();
|
||||
console.log( store.getState())
|
||||
if(token.accessToken==='')
|
||||
navigate('/login')
|
||||
useEffect(() => {
|
||||
if(token.accessToken===''){
|
||||
console.log("redirect")
|
||||
navigate("/login")
|
||||
}
|
||||
}, []);
|
||||
return (
|
||||
<div className="HomeView">
|
||||
<p>{token.accessToken}</p>
|
||||
|
|
|
@ -15,7 +15,10 @@ function LoginView() {
|
|||
|
||||
const onFinish = (values: any) => {
|
||||
console.log(values)
|
||||
axios.post(baseUrl + 'login', values).then(function (response) {
|
||||
const data = new FormData();
|
||||
data.append('staffId', values.staffId);
|
||||
data.append('staffPassword', values.staffPassword);
|
||||
axios.post(baseUrl + 'login', data).then(function (response) {
|
||||
console.log(response.data)
|
||||
dispatch(setToken({
|
||||
accessToken: response.data.accessToken,
|
||||
|
|
Loading…
Reference in New Issue