refactor: 优化前端网络层

- 优化AuthService认证服务
- 更新AuthModels数据模型
- 更新MemoirModels数据模型
This commit is contained in:
iammm0
2026-01-29 10:57:09 +08:00
parent 32fdc066dd
commit 2b9f79070d
3 changed files with 9 additions and 6 deletions

View File

@@ -326,13 +326,14 @@ class AuthService {
}
/**
* 验证码登录
* 验证码登录/注册(统一接口)
* 如果用户不存在会自动注册需要提供nickname
*/
suspend fun loginWithSms(phone: String, code: String, agreedToTerms: Boolean): Result<TokenResponse> {
suspend fun loginWithSms(phone: String, code: String, agreedToTerms: Boolean, nickname: String? = null): Result<TokenResponse> {
return try {
val response = client.post("$AUTH_BASE/login/sms") {
contentType(ContentType.Application.Json)
setBody(SmsLoginRequest(phone, code, agreedToTerms))
setBody(SmsLoginRequest(phone, code, agreedToTerms, nickname))
}
when (response.status) {

View File

@@ -89,12 +89,13 @@ data class SmsResponse(
val expires_in: Int
)
// 验证码登录请求
// 验证码登录/注册请求(统一接口)
@Serializable
data class SmsLoginRequest(
val phone: String,
val code: String,
val agreed_to_terms: Boolean
val agreed_to_terms: Boolean,
val nickname: String? = null // 昵称(首次登录/注册时必填)
)
// 验证码注册请求

View File

@@ -44,7 +44,8 @@ data class ChapterContentDto(
val category: String,
val pageCount: Int?,
val updatedAt: Long,
val quotes: List<String> = emptyList() // 引用内容列表
val quotes: List<String> = emptyList(), // 引用内容列表
val images: List<String> = emptyList() // 图片列表
)
// 回忆录状态DTO