优化前端认证与类型管理
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { apiClient } from './client'
|
||||
import type { ApiResponse } from './types'
|
||||
import type { RealnameStatusValue, RiskStatus, UserStatus } from '@/types/status'
|
||||
|
||||
export interface AuthUser {
|
||||
id: number
|
||||
phone: string
|
||||
nickname: string
|
||||
avatar_url: string
|
||||
realname_status: string
|
||||
risk_status: string
|
||||
realname_status: RealnameStatusValue
|
||||
risk_status: RiskStatus
|
||||
credit_score: number
|
||||
status: string
|
||||
status: UserStatus
|
||||
}
|
||||
|
||||
export interface TokenPair {
|
||||
@@ -23,12 +25,6 @@ export interface LoginData {
|
||||
tokens: TokenPair
|
||||
}
|
||||
|
||||
interface ApiResponse<T> {
|
||||
code: string
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
|
||||
export async function sendSmsCode(phone: string) {
|
||||
const { data } = await apiClient.post<ApiResponse<{ phone: string; expires_in: number }>>('/auth/sms/send', {
|
||||
phone,
|
||||
@@ -57,4 +53,4 @@ export async function refreshUserToken(refreshToken: string) {
|
||||
refresh_token: refreshToken,
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user