mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
perf: Adapting the unified response model
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user