perf: Adapting the unified response model

This commit is contained in:
fit2cloud-chenyw
2025-05-08 16:06:51 +08:00
parent f2315cf2d9
commit 62acfb7569
3 changed files with 7 additions and 5 deletions
-3
View File
@@ -6,9 +6,6 @@ export const AuthApi = {
}>('/login/access-token', credentials, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
requestOptions: {
rawResponse: true,
}
}),
logout: () => request.post('/auth/logout')
+2 -2
View File
@@ -9,8 +9,8 @@ export const useUserStore = defineStore('user', () => {
const login = async (formData: { username: string; password: string }) => {
username.value = formData.username
const res = await AuthApi.login(formData)
token.value = res.data.access_token
const res: any = await AuthApi.login(formData)
token.value = res.access_token
wsCache.set('user.token', token.value)
username.value = formData.username
}
+5
View File
@@ -94,6 +94,11 @@ class HttpService {
/* if (response.data?.success !== true) {
return Promise.reject(response.data)
} */
if (response.data?.code === 0) {
return response.data.data
} else if (response.data?.code) {
return Promise.reject(response.data)
}
return response.data
},
async (error: AxiosError) => {