主页分类动态获取
This commit is contained in:
@@ -5,7 +5,8 @@ object ConstVars {
|
|||||||
// Debug: http://192.168.0.201:8088
|
// Debug: http://192.168.0.201:8088
|
||||||
// Release: https://rider-pro.aiosman.com/beta_api
|
// Release: https://rider-pro.aiosman.com/beta_api
|
||||||
val BASE_SERVER = if (BuildConfig.DEBUG) {
|
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 {
|
} else {
|
||||||
"https://rider-pro.aiosman.com/beta_api" // Release环境
|
"https://rider-pro.aiosman.com/beta_api" // Release环境
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -654,8 +654,9 @@ interface RaveNowAPI {
|
|||||||
@Query("withChildren") withChildren: Boolean? = null,
|
@Query("withChildren") withChildren: Boolean? = null,
|
||||||
@Query("withParent") withParent: Boolean? = null,
|
@Query("withParent") withParent: Boolean? = null,
|
||||||
@Query("withCount") withCount: Boolean? = null,
|
@Query("withCount") withCount: Boolean? = null,
|
||||||
@Query("hideEmpty") hideEmpty: Boolean? = null
|
@Query("hideEmpty") hideEmpty: Boolean? = null,
|
||||||
): Response<DataContainer<CategoryListResponse>>
|
@Query("lang") lang: String? = null
|
||||||
|
): Response<CategoryListResponse>
|
||||||
|
|
||||||
@GET("outside/categories/tree")
|
@GET("outside/categories/tree")
|
||||||
suspend fun getCategoryTree(
|
suspend fun getCategoryTree(
|
||||||
|
|||||||
@@ -146,11 +146,14 @@ fun Agent() {
|
|||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = {
|
title = {
|
||||||
androidx.compose.material3.Text(
|
Image(
|
||||||
text = "Rave AI",
|
painter = painterResource(id = R.drawable.home_logo),
|
||||||
fontSize = 20.sp,
|
contentDescription = "Rave AI Logo",
|
||||||
fontWeight = FontWeight.W900,
|
modifier = Modifier
|
||||||
color = AppColors.text
|
.height(44.dp)
|
||||||
|
.padding(top =9.dp,bottom=9.dp)
|
||||||
|
.wrapContentSize(),
|
||||||
|
// colorFilter = ColorFilter.tint(AppColors.text)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
@@ -158,7 +161,8 @@ fun Agent() {
|
|||||||
painter = painterResource(id = R.drawable.rider_pro_nav_search),
|
painter = painterResource(id = R.drawable.rider_pro_nav_search),
|
||||||
contentDescription = "search",
|
contentDescription = "search",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(24.dp)
|
.size(44.dp)
|
||||||
|
.padding(top = 9.dp,bottom=9.dp)
|
||||||
.noRippleClickable {
|
.noRippleClickable {
|
||||||
navController.navigate(NavigationRoute.Search.route)
|
navController.navigate(NavigationRoute.Search.route)
|
||||||
},
|
},
|
||||||
@@ -167,7 +171,11 @@ fun Agent() {
|
|||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = AppColors.background
|
containerColor = AppColors.background
|
||||||
)
|
),
|
||||||
|
windowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
|
modifier = Modifier
|
||||||
|
.height(44.dp + statusBarPaddingValues.calculateTopPadding())
|
||||||
|
.padding(top = statusBarPaddingValues.calculateTopPadding())
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
containerColor = AppColors.background,
|
containerColor = AppColors.background,
|
||||||
@@ -180,8 +188,8 @@ fun Agent() {
|
|||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.padding(
|
.padding(
|
||||||
bottom = navigationBarPaddings,
|
bottom = navigationBarPaddings,
|
||||||
start = 16.dp,
|
start = 8.dp,
|
||||||
end = 16.dp
|
end = 8.dp
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -217,7 +225,7 @@ fun Agent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 动态添加分类标签
|
// 动态添加分类标签
|
||||||
viewModel.categories.take(4).forEachIndexed { index, category ->
|
viewModel.categories.forEachIndexed { index, category ->
|
||||||
item {
|
item {
|
||||||
CustomTabItem(
|
CustomTabItem(
|
||||||
text = category.name,
|
text = category.name,
|
||||||
@@ -233,58 +241,6 @@ fun Agent() {
|
|||||||
TabSpacer()
|
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
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.NavigationRoute
|
||||||
import com.aiosman.ravenow.ui.index.tabs.message.MessageListViewModel.userService
|
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.ui.index.tabs.moment.tabs.expolre.AgentItem
|
||||||
|
import com.aiosman.ravenow.utils.Utils
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
object AgentViewModel: ViewModel() {
|
object AgentViewModel: ViewModel() {
|
||||||
@@ -122,15 +123,18 @@ object AgentViewModel: ViewModel() {
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val response = apiClient.getCategories(
|
val response = apiClient.getCategories(
|
||||||
pageSize = 20,
|
page = 1,
|
||||||
|
pageSize = 100,
|
||||||
|
isActive = true,
|
||||||
withChildren = false,
|
withChildren = false,
|
||||||
withParent = false,
|
withParent = false,
|
||||||
withCount = true,
|
withCount = true,
|
||||||
hideEmpty = true
|
hideEmpty = true,
|
||||||
|
lang = Utils.getCurrentLanguage()
|
||||||
)
|
)
|
||||||
println("分类数据请求完成,响应成功: ${response.isSuccessful}")
|
println("分类数据请求完成,响应成功: ${response.isSuccessful}")
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
val categoryList = response.body()?.data?.list ?: emptyList()
|
val categoryList = response.body()?.list ?: emptyList()
|
||||||
println("获取到 ${categoryList.size} 个分类")
|
println("获取到 ${categoryList.size} 个分类")
|
||||||
categories = categoryList.map { category ->
|
categories = categoryList.map { category ->
|
||||||
CategoryItem.fromCategoryTemplate(category)
|
CategoryItem.fromCategoryTemplate(category)
|
||||||
|
|||||||
22
app/src/main/res/drawable/home_logo.xml
Normal file
22
app/src/main/res/drawable/home_logo.xml
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
Reference in New Issue
Block a user