From 0dad3f206e152b3e70962fbb87e6736ca390c37e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com>
Date: Thu, 2 Mar 2023 17:52:54 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2=E5=88=9D?=
=?UTF-8?q?=E6=AD=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/internal/httpClient.ts | 3 +++
src/api/login.ts | 4 ++++
src/api/system.ts | 4 ----
src/pages/login/Login.tsx | 17 ++---------------
4 files changed, 9 insertions(+), 19 deletions(-)
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 (
-