refactor axios.

This commit is contained in:
2023-01-08 14:42:54 +08:00
parent 7bea386dbc
commit e306e6b463
16 changed files with 270 additions and 113 deletions

View File

@@ -1,7 +1,10 @@
import { useAxios } from "@vueuse/integrations/useAxios"
import http from "../utils/http"
export function login(data: { username: string; password: string }) {
return http.post("login", data)
return useAxios("login", { method: "post", data }, http, {
immediate: false,
})
}
export function logout() {
@@ -9,7 +12,7 @@ export function logout() {
}
export function getUserInfo(username: string) {
return http.get("profile", {
params: { username },
return useAxios("profile", { method: "get", params: { username } }, http, {
immediate: false,
})
}