[merge] Merge branch 'dev-optimize1'

This commit is contained in:
acite
2025-08-25 17:24:20 +08:00
6 changed files with 44 additions and 14 deletions

View File

@@ -24,6 +24,7 @@ _🚀This is the client of the multimedia server Abyss, which can also be extend
### High Priority
- [x] Fix tablet full-screen mode bug
- [x] Hide private key after user input
- [x] Optimize API call logic, do not create crashes
- [ ] Replace Android robot icon with custom design
- [ ] Configure server baseURL in client settings
- [ ] Implement proper access control for directory queries

View File

@@ -12,23 +12,39 @@ object MediaManager
var token: String = "null"
suspend fun listVideoKlasses(): List<String>
{
try
{
val j = ApiClient.api.getVideoClasses(token)
return j.toList()
}catch(e: Exception)
{
return listOf()
}
}
suspend fun listVideos(klass: String): List<Video>
{
try {
val j = ApiClient.api.queryVideoClasses(klass, token)
return j.map{
queryVideo(klass, it)
queryVideo(klass, it)!!
}.toList()
}catch (e: Exception)
{
return listOf()
}
}
suspend fun queryVideo(klass: String, id: String): Video
suspend fun queryVideo(klass: String, id: String): Video?
{
try {
val j = ApiClient.api.queryVideo(klass, id, token)
return Video(klass = klass, id = id, token=token, j)
}catch (e: Exception)
{
return null
}
}
suspend fun listComics() : List<String>

View File

@@ -50,9 +50,11 @@ object RecentManager
try{
val r = Json.decodeFromString<List<VideoQueryIndex>>(content)
_recent.value = r.map{
val vn = r.map{
MediaManager.queryVideo(it.klass, it.id)
}
}.filter { it != null }
_recent.value = vn.map { it!! }
return r
}catch (e: Exception)
{
@@ -82,9 +84,12 @@ object RecentManager
if(o.size >= 21)
o.removeAt(o.size - 1)
_recent.value = o.map{
val vn = o.map{
MediaManager.queryVideo(it.klass, it.id)
}
}.filter { it != null }
_recent.value = vn.map { it!! }
writeFile(context, "recent.json", Json.encodeToString(o))
}
}

View File

@@ -25,6 +25,7 @@ import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import com.acitelight.aether.Global
import com.acitelight.aether.service.MediaManager
import com.acitelight.aether.service.RecentManager
import com.acitelight.aether.viewModel.HomeScreenViewModel
@@ -55,6 +56,7 @@ fun HomeScreen(homeScreenViewModel: HomeScreenViewModel = viewModel(), navContro
.padding(horizontal = 12.dp),
i,
{
Global.sameClassVideos = recent
val route = "video_player_route/${ "${i.klass}/${i.id}".toHex() }"
navController.navigate(route)
})

View File

@@ -914,6 +914,7 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
@Composable
fun MiniVideoCard(modifier: Modifier, video: Video, onClick: () -> Unit)
{
var isImageLoaded by remember { mutableStateOf(false) }
Card(
modifier = modifier.height(80.dp).fillMaxWidth(),
colors = CardColors(
@@ -932,6 +933,11 @@ fun MiniVideoCard(modifier: Modifier, video: Video, onClick: () -> Unit)
.data(video.getCover())
.memoryCacheKey("${video.klass}/${video.id}/cover")
.diskCacheKey("${video.klass}/${video.id}/cover")
.listener(
onStart = { },
onSuccess = { _, _ -> isImageLoaded = true },
onError = { _, _ -> }
)
.build(),
contentDescription = null,
modifier = Modifier

View File

@@ -55,7 +55,7 @@ class VideoPlayerViewModel() : ViewModel()
remember {
viewModelScope.launch {
video = MediaManager.queryVideo(v.split("/")[0], v.split("/")[1])
video = MediaManager.queryVideo(v.split("/")[0], v.split("/")[1])!!
RecentManager.Push(context, VideoQueryIndex(v.split("/")[0], v.split("/")[1]))
_player = ExoPlayer.Builder(context).build().apply {
val url = video?.getVideo() ?: ""