主页分类动态获取

This commit is contained in:
2025-10-17 16:56:25 +08:00
parent 58a2013a8f
commit 4bdbbb0231
8 changed files with 52 additions and 68 deletions

View File

@@ -5,7 +5,8 @@ object ConstVars {
// 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环境
// "http://47.109.137.67:6363" // Debug环境
"https://rider-pro.aiosman.com/beta_api" // Release环境
} else {
"https://rider-pro.aiosman.com/beta_api" // Release环境
}

View File

@@ -654,8 +654,9 @@ interface RaveNowAPI {
@Query("withChildren") withChildren: Boolean? = null,
@Query("withParent") withParent: Boolean? = null,
@Query("withCount") withCount: Boolean? = null,
@Query("hideEmpty") hideEmpty: Boolean? = null
): Response<DataContainer<CategoryListResponse>>
@Query("hideEmpty") hideEmpty: Boolean? = null,
@Query("lang") lang: String? = null
): Response<CategoryListResponse>
@GET("outside/categories/tree")
suspend fun getCategoryTree(

View File

@@ -146,11 +146,14 @@ fun Agent() {
topBar = {
TopAppBar(
title = {
androidx.compose.material3.Text(
text = "Rave AI",
fontSize = 20.sp,
fontWeight = FontWeight.W900,
color = AppColors.text
Image(
painter = painterResource(id = R.drawable.home_logo),
contentDescription = "Rave AI Logo",
modifier = Modifier
.height(44.dp)
.padding(top =9.dp,bottom=9.dp)
.wrapContentSize(),
// colorFilter = ColorFilter.tint(AppColors.text)
)
},
actions = {
@@ -158,7 +161,8 @@ fun Agent() {
painter = painterResource(id = R.drawable.rider_pro_nav_search),
contentDescription = "search",
modifier = Modifier
.size(24.dp)
.size(44.dp)
.padding(top = 9.dp,bottom=9.dp)
.noRippleClickable {
navController.navigate(NavigationRoute.Search.route)
},
@@ -167,7 +171,11 @@ fun Agent() {
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = AppColors.background
)
),
windowInsets = WindowInsets(0, 0, 0, 0),
modifier = Modifier
.height(44.dp + statusBarPaddingValues.calculateTopPadding())
.padding(top = statusBarPaddingValues.calculateTopPadding())
)
},
containerColor = AppColors.background,
@@ -180,8 +188,8 @@ fun Agent() {
.padding(paddingValues)
.padding(
bottom = navigationBarPaddings,
start = 16.dp,
end = 16.dp
start = 8.dp,
end = 8.dp
)
) {
@@ -217,7 +225,7 @@ fun Agent() {
}
// 动态添加分类标签
viewModel.categories.take(4).forEachIndexed { index, category ->
viewModel.categories.forEachIndexed { index, category ->
item {
CustomTabItem(
text = category.name,
@@ -233,58 +241,6 @@ fun Agent() {
TabSpacer()
}
}
item {
CustomTabItem(
text = "scenes",
isSelected = selectedTabIndex == 1,
onClick = {
selectedTabIndex = 1
}
)
}
item {
TabSpacer()
}
item {
CustomTabItem(
text = "voices",
isSelected = selectedTabIndex == 6,
onClick = {
selectedTabIndex = 6
}
)
}
item {
TabSpacer()
}
item {
CustomTabItem(
text = "anime",
isSelected = selectedTabIndex == 7,
onClick = {
selectedTabIndex = 7
}
)
}
item {
TabSpacer()
}
item {
CustomTabItem(
text = "assist",
isSelected = selectedTabIndex == 8,
onClick = {
selectedTabIndex = 8
}
)
}
}
}
}

View File

@@ -16,6 +16,7 @@ import com.aiosman.ravenow.ui.index.tabs.ai.tabs.mine.MineAgentViewModel.createG
import com.aiosman.ravenow.ui.NavigationRoute
import com.aiosman.ravenow.ui.index.tabs.message.MessageListViewModel.userService
import com.aiosman.ravenow.ui.index.tabs.moment.tabs.expolre.AgentItem
import com.aiosman.ravenow.utils.Utils
import kotlinx.coroutines.launch
object AgentViewModel: ViewModel() {
@@ -122,15 +123,18 @@ object AgentViewModel: ViewModel() {
viewModelScope.launch {
try {
val response = apiClient.getCategories(
pageSize = 20,
page = 1,
pageSize = 100,
isActive = true,
withChildren = false,
withParent = false,
withCount = true,
hideEmpty = true
hideEmpty = true,
lang = Utils.getCurrentLanguage()
)
println("分类数据请求完成,响应成功: ${response.isSuccessful}")
if (response.isSuccessful) {
val categoryList = response.body()?.data?.list ?: emptyList()
val categoryList = response.body()?.list ?: emptyList()
println("获取到 ${categoryList.size} 个分类")
categories = categoryList.map { category ->
CategoryItem.fromCategoryTemplate(category)