diff --git a/src/api/internal/httpClient.ts b/src/api/internal/httpClient.ts index c635ca0..43c915e 100644 --- a/src/api/internal/httpClient.ts +++ b/src/api/internal/httpClient.ts @@ -10,6 +10,9 @@ export class HttpClient { baseURL: url, timeout: 15000, withCredentials: false, + headers:{ + "Accept":"application/json" + } }); //拦截器注册 diff --git a/src/api/login.ts b/src/api/login.ts index fdf002e..e733c8e 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -17,3 +17,7 @@ export function login( export function logout() { return client.post("/backend/v1/auth/logout", {}); } + +export function getUser() { + return client.get("/backend/v1/auth/detail", {}); +} \ No newline at end of file diff --git a/src/api/system.ts b/src/api/system.ts index d038bb1..ee2ccb4 100644 --- a/src/api/system.ts +++ b/src/api/system.ts @@ -4,7 +4,3 @@ export function getImageCaptcha() { return client.get("/backend/v1/system/image-captcha", {}); } -export function getUser() { - return client.get("/backend/v1/auth/detail", {}); - } - diff --git a/src/pages/login/Login.tsx b/src/pages/login/Login.tsx index f585b4f..f4efc6d 100644 --- a/src/pages/login/Login.tsx +++ b/src/pages/login/Login.tsx @@ -57,7 +57,7 @@ export const Login: React.FC = (defaultState) => { }; const getUser = () => { - system.getUser().then((res) => { + login.getUser().then((res) => { console.log(res); }); }; @@ -65,20 +65,7 @@ export const Login: React.FC = (defaultState) => { useEffect(() => { fetchData(); }, []); - if (loading) { - return ( - - ); - } + return (