- 添加 AuthCoinAmount 类型和 AuthWithdrawAccount 接口 - 在 AuthUser 和相关 DTO 中增加余额和提款账户字段 - 将获取用户资料的请求方法从 POST 改为 GET - 实现提款账户信息的默认值设置和状态管理 - 添加 JackpotPoolTicker 组件并在状态栏中显示 - 更新多语言文件中的游戏规则说明 - 实现提款表单的预填充和状态重置功能
87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
import type {
|
|
AuthSessionDto,
|
|
AuthSessionInput,
|
|
AuthUser,
|
|
AuthUserDto,
|
|
AuthUserProfileDto,
|
|
RefreshTokenDto,
|
|
} from '@/type'
|
|
|
|
export function normalizeAuthUser(dto: AuthUserDto): AuthUser {
|
|
return {
|
|
channelId: dto.channel_id,
|
|
coin: dto.coin,
|
|
id: dto.uuid,
|
|
name: dto.username,
|
|
phone: dto.phone,
|
|
riskFlags: dto.risk_flags,
|
|
username: dto.username,
|
|
uuid: dto.uuid,
|
|
}
|
|
}
|
|
|
|
export function normalizeAuthUserProfile(dto: AuthUserProfileDto): AuthUser {
|
|
return {
|
|
channelId: dto.channel_id,
|
|
coin: dto.coin,
|
|
coinBalance: dto.coin_balance,
|
|
createTime: dto.create_time,
|
|
currentStreak: dto.current_streak,
|
|
email: dto.email,
|
|
frozenBalance: dto.frozen_balance,
|
|
headImage: dto.head_image,
|
|
id: dto.uuid,
|
|
lastBetPeriodNo: dto.last_bet_period_no,
|
|
name: dto.username,
|
|
phone: dto.phone,
|
|
registerInviteCode: dto.register_invite_code,
|
|
riskFlags: dto.risk_flags,
|
|
totalDepositCoin: dto.total_deposit_coin,
|
|
totalWithdrawCoin: dto.total_withdraw_coin,
|
|
username: dto.username,
|
|
uuid: dto.uuid,
|
|
withdraw: dto.withdraw
|
|
? {
|
|
receiveAccount: dto.withdraw.receive_account,
|
|
receiverEmail: dto.withdraw.receiver_email,
|
|
receiverMobile: dto.withdraw.receiver_mobile,
|
|
receiverName: dto.withdraw.receiver_name,
|
|
}
|
|
: undefined,
|
|
}
|
|
}
|
|
|
|
export function mergeAuthUsers(
|
|
baseUser: AuthUser | null | undefined,
|
|
profileUser: AuthUser | null | undefined,
|
|
): AuthUser | null {
|
|
if (!baseUser && !profileUser) {
|
|
return null
|
|
}
|
|
|
|
return {
|
|
...baseUser,
|
|
...profileUser,
|
|
id: profileUser?.id ?? baseUser?.id ?? '',
|
|
}
|
|
}
|
|
|
|
export function normalizeAuthSession(dto: AuthSessionDto): AuthSessionInput {
|
|
return {
|
|
accessToken: dto['user-token'],
|
|
accessTokenExpiresAt: Date.now() + dto.expires_in * 1000,
|
|
currentUser: normalizeAuthUser(dto.user),
|
|
refreshToken: dto.refresh_token ?? null,
|
|
}
|
|
}
|
|
|
|
export function normalizeRefreshAuthSession(
|
|
dto: RefreshTokenDto,
|
|
): AuthSessionInput {
|
|
return {
|
|
accessToken: dto['user-token'],
|
|
accessTokenExpiresAt: Date.now() + dto.expires_in * 1000,
|
|
refreshToken: dto.refresh_token ?? null,
|
|
}
|
|
}
|