Files
36-character-flower/src/type/auth.type.ts
JiaJun 9ade40c29b feat(auth): 更新用户认证类型定义并优化提款功能
- 添加 AuthCoinAmount 类型和 AuthWithdrawAccount 接口
- 在 AuthUser 和相关 DTO 中增加余额和提款账户字段
- 将获取用户资料的请求方法从 POST 改为 GET
- 实现提款账户信息的默认值设置和状态管理
- 添加 JackpotPoolTicker 组件并在状态栏中显示
- 更新多语言文件中的游戏规则说明
- 实现提款表单的预填充和状态重置功能
2026-07-15 18:00:33 +08:00

199 lines
3.8 KiB
TypeScript

import type { SMS_SEND_EVENT_REGISTER } from '@/constants'
export type AuthStatus = 'anonymous' | 'authenticated' | 'restoring'
export type AuthSubmitContext = 'login' | 'register'
export type AuthCoinAmount = number | string
export interface AuthWithdrawAccount {
receiveAccount?: string
receiverEmail?: string
receiverMobile?: string
receiverName?: string
}
export interface AuthUser {
createTime?: number
channelId?: number
coin?: AuthCoinAmount
coinBalance?: number
currentStreak?: number
email?: string
frozenBalance?: number
headImage?: string
id: string
isJackpot?: boolean
lastBetPeriodNo?: string
name?: string
oddsFactor?: number
phone?: string
registerInviteCode?: string
riskFlags?: number
roles?: string[]
streakLevel?: number
totalDepositCoin?: number
totalWithdrawCoin?: number
username?: string
uuid?: string
withdraw?: AuthWithdrawAccount
}
export interface AuthSessionInput {
accessToken: string
accessTokenExpiresAt?: number | null
currentUser?: AuthUser | null
refreshToken?: string | null
}
export interface AuthApiEnvelope<T> {
code: number
data: T
message?: string
msg?: string
}
export interface AuthTokenDto {
auth_token: string
expires_in: number
server_time: number
}
export interface AuthUserDto {
channel_id: number
coin: AuthCoinAmount
phone?: string
risk_flags: number
username: string
uuid: string
}
export interface AuthSessionDto {
expires_in: number
refresh_token?: string | null
user: AuthUserDto
'user-token': string
}
export interface RefreshTokenDto {
expires_in: number
refresh_token?: string | null
'user-token': string
}
export interface AuthUserProfileDto {
channel_id: number
coin: number
coin_balance: number
create_time: number
current_streak: number
email: string
frozen_balance: number
head_image: string
last_bet_period_no: string
phone: string
register_invite_code: string
risk_flags: number
total_deposit_coin: number
total_withdraw_coin: number
username: string
uuid: string
withdraw?: {
receive_account: string
receiver_email: string
receiver_mobile: string
receiver_name: string
} | null
}
export interface LoginRequestDto {
device_id?: string
password: string
username: string
}
export interface LogoutRequestDto {
password: string
username: string
}
export interface RegisterRequestDto {
captcha: string
device_id?: string
invite_code: string
password: string
username: string
}
export interface SendSmsCodeRequestDto {
event: typeof SMS_SEND_EVENT_REGISTER
mobile: string
}
export interface SendSmsCodeDto {
expires_in: number
message_id: string
}
export interface RefreshTokenRequestDto {
refresh_token: string
}
export interface LoginPayload {
password: string
username: string
}
export type LogoutPayload = LoginPayload
export interface RegisterPayload {
captcha: string
inviteCode: string
mobile: string
password: string
}
export interface SendSmsCodePayload {
mobile: string
}
export interface SendSmsCodeResult {
expiresIn: number
messageId: string
}
export type LoginFormValues = { password: string; username: string }
export type RegisterFormValues = {
captcha: string
confirmPassword: string
inviteCode: string
mobile: string
password: string
}
export interface UseLoginFormOptions {
onSuccess?: () => void
}
export interface UseRegisterFormOptions {
onSuccess?: () => void
}
export interface ClearAuthenticatedSessionOptions {
clearBrowserStorage?: boolean
clearQueryCache?: boolean
}
export interface UnauthorizedSessionOptions
extends ClearAuthenticatedSessionOptions {
openLoginModal?: boolean
showLoginRequiredToast?: boolean
}
export type CurrentUserInitializer = () => Promise<AuthUser | null>
export type RefreshSessionHandler = (
refreshToken: string,
) => Promise<AuthSessionInput | null>