修复一些未处理异常,切换到测试服务器
This commit is contained in:
@@ -32,6 +32,9 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
isDebuggable = true
|
||||
}
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
@@ -49,6 +52,7 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.3"
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.aiosman.ravenow
|
||||
|
||||
object ConstVars {
|
||||
// api 地址
|
||||
// const val BASE_SERVER = "http://192.168.31.131:8088"
|
||||
const val BASE_SERVER = "http://192.168.0.201:8088"
|
||||
// const val BASE_SERVER = "http://192.168.0.228:8088"
|
||||
// const val BASE_SERVER = "https://rider-pro.aiosman.com/beta_api"
|
||||
// api 地址 - 根据构建类型自动选择
|
||||
// Debug: http://192.168.0.201:8088
|
||||
// Release: https://rider-pro.aiosman.com/beta_api
|
||||
val BASE_SERVER = if (BuildConfig.DEBUG) {
|
||||
"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_NAME = "Moment Like"
|
||||
|
||||
@@ -91,7 +91,7 @@ interface AgentService {
|
||||
pageNumber: Int,
|
||||
pageSize: Int = 20,
|
||||
authorId: Int? = null
|
||||
): ListContainer<AgentEntity>
|
||||
): ListContainer<AgentEntity>?
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ class AuthInterceptor() : Interceptor {
|
||||
}
|
||||
|
||||
object ApiClient {
|
||||
const val BASE_SERVER = ConstVars.BASE_SERVER
|
||||
const val BASE_API_URL = "${BASE_SERVER}/api/v1"
|
||||
const val RETROFIT_URL = "${BASE_API_URL}/"
|
||||
val BASE_SERVER = ConstVars.BASE_SERVER
|
||||
val BASE_API_URL = "${BASE_SERVER}/api/v1"
|
||||
val RETROFIT_URL = "${BASE_API_URL}/"
|
||||
const val TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"
|
||||
private val okHttpClient: OkHttpClient by lazy {
|
||||
getSafeOkHttpClient(authInterceptor = AuthInterceptor())
|
||||
|
||||
@@ -80,9 +80,9 @@ class AgentPagingSource(
|
||||
authorId = authorId
|
||||
)
|
||||
LoadResult.Page(
|
||||
data = users.list,
|
||||
data = users?.list ?: listOf(),
|
||||
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) {
|
||||
return LoadResult.Error(exception)
|
||||
@@ -102,7 +102,7 @@ class AgentRemoteDataSource(
|
||||
suspend fun getAgent(
|
||||
pageNumber: Int,
|
||||
authorId: Int? = null
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
return agentService.getAgent(
|
||||
pageNumber = pageNumber,
|
||||
authorId = authorId
|
||||
@@ -117,7 +117,7 @@ class AgentServiceImpl() : AgentService {
|
||||
pageNumber: Int,
|
||||
pageSize: Int,
|
||||
authorId: Int?
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
return agentBackend.getAgent(
|
||||
pageNumber = pageNumber,
|
||||
authorId = authorId
|
||||
@@ -130,7 +130,7 @@ class AgentBackend {
|
||||
suspend fun getAgent(
|
||||
pageNumber: Int,
|
||||
authorId: Int? = null
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
// 如果是游客模式且获取我的Agent(authorId为null),返回空列表
|
||||
if (authorId == null && AppStore.isGuest) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user