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