修复一些未处理异常,切换到测试服务器

This commit is contained in:
2025-09-10 18:34:36 +08:00
parent c41c097d41
commit 57e4614ce8
5 changed files with 22 additions and 15 deletions

View File

@@ -32,6 +32,9 @@ android {
} }
buildTypes { buildTypes {
debug {
isDebuggable = true
}
release { release {
isMinifyEnabled = false isMinifyEnabled = false
proguardFiles( proguardFiles(
@@ -49,6 +52,7 @@ android {
} }
buildFeatures { buildFeatures {
compose = true compose = true
buildConfig = true
} }
composeOptions { composeOptions {
kotlinCompilerExtensionVersion = "1.5.3" kotlinCompilerExtensionVersion = "1.5.3"

View File

@@ -1,11 +1,14 @@
package com.aiosman.ravenow package com.aiosman.ravenow
object ConstVars { object ConstVars {
// api 地址 // api 地址 - 根据构建类型自动选择
// const val BASE_SERVER = "http://192.168.31.131:8088" // Debug: http://192.168.0.201:8088
const val BASE_SERVER = "http://192.168.0.201:8088" // Release: https://rider-pro.aiosman.com/beta_api
// const val BASE_SERVER = "http://192.168.0.228:8088" val BASE_SERVER = if (BuildConfig.DEBUG) {
// const val BASE_SERVER = "https://rider-pro.aiosman.com/beta_api" "http://47.109.137.67:6363" // Debug环境
} else {
"https://rider-pro.aiosman.com/beta_api" // Release环境
}
const val MOMENT_LIKE_CHANNEL_ID = "moment_like" const val MOMENT_LIKE_CHANNEL_ID = "moment_like"
const val MOMENT_LIKE_CHANNEL_NAME = "Moment Like" const val MOMENT_LIKE_CHANNEL_NAME = "Moment Like"

View File

@@ -91,7 +91,7 @@ interface AgentService {
pageNumber: Int, pageNumber: Int,
pageSize: Int = 20, pageSize: Int = 20,
authorId: Int? = null authorId: Int? = null
): ListContainer<AgentEntity> ): ListContainer<AgentEntity>?
} }

View File

@@ -70,9 +70,9 @@ class AuthInterceptor() : Interceptor {
} }
object ApiClient { object ApiClient {
const val BASE_SERVER = ConstVars.BASE_SERVER val BASE_SERVER = ConstVars.BASE_SERVER
const val BASE_API_URL = "${BASE_SERVER}/api/v1" val BASE_API_URL = "${BASE_SERVER}/api/v1"
const val RETROFIT_URL = "${BASE_API_URL}/" val RETROFIT_URL = "${BASE_API_URL}/"
const val TIME_FORMAT = "yyyy-MM-dd HH:mm:ss" const val TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"
private val okHttpClient: OkHttpClient by lazy { private val okHttpClient: OkHttpClient by lazy {
getSafeOkHttpClient(authInterceptor = AuthInterceptor()) getSafeOkHttpClient(authInterceptor = AuthInterceptor())

View File

@@ -80,9 +80,9 @@ class AgentPagingSource(
authorId = authorId authorId = authorId
) )
LoadResult.Page( LoadResult.Page(
data = users.list, data = users?.list ?: listOf(),
prevKey = if (currentPage == 1) null else currentPage - 1, prevKey = if (currentPage == 1) null else currentPage - 1,
nextKey = if (users.list.isEmpty()) null else users.page + 1 nextKey = if (users?.list?.isNotEmpty() == true) users.page + 1 else null
) )
} catch (exception: IOException) { } catch (exception: IOException) {
return LoadResult.Error(exception) return LoadResult.Error(exception)
@@ -102,7 +102,7 @@ class AgentRemoteDataSource(
suspend fun getAgent( suspend fun getAgent(
pageNumber: Int, pageNumber: Int,
authorId: Int? = null authorId: Int? = null
): ListContainer<AgentEntity> { ): ListContainer<AgentEntity>? {
return agentService.getAgent( return agentService.getAgent(
pageNumber = pageNumber, pageNumber = pageNumber,
authorId = authorId authorId = authorId
@@ -117,7 +117,7 @@ class AgentServiceImpl() : AgentService {
pageNumber: Int, pageNumber: Int,
pageSize: Int, pageSize: Int,
authorId: Int? authorId: Int?
): ListContainer<AgentEntity> { ): ListContainer<AgentEntity>? {
return agentBackend.getAgent( return agentBackend.getAgent(
pageNumber = pageNumber, pageNumber = pageNumber,
authorId = authorId authorId = authorId
@@ -130,7 +130,7 @@ class AgentBackend {
suspend fun getAgent( suspend fun getAgent(
pageNumber: Int, pageNumber: Int,
authorId: Int? = null authorId: Int? = null
): ListContainer<AgentEntity> { ): ListContainer<AgentEntity>? {
// 如果是游客模式且获取我的AgentauthorId为null返回空列表 // 如果是游客模式且获取我的AgentauthorId为null返回空列表
if (authorId == null && AppStore.isGuest) { if (authorId == null && AppStore.isGuest) {
return ListContainer( return ListContainer(
@@ -154,7 +154,7 @@ class AgentBackend {
) )
} }
val body = resp.body() ?: throw ServiceException("Failed to get agents") val body = resp.body() ?: return null
// 处理不同的返回类型 // 处理不同的返回类型
return if (authorId != null) { return if (authorId != null) {