fix: 修复桌面图标回前台保留阅读路由

This commit is contained in:
HapeLee
2026-06-14 13:20:45 +08:00
parent fef2ebd990
commit aa3186d0df
@@ -184,6 +184,7 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
if (!intent.hasExplicitStartRoute()) return
routeEvents.tryEmit(MainNavigator.resolveStartRoute(intent))
}
@@ -204,7 +205,7 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
val startRoutes = remember {
val resolved = MainNavigator.resolveStartRoute(intent)
val hasExplicitStartRoute = intent?.hasExtra(MainIntent.EXTRA_START_ROUTE) == true
val hasExplicitStartRoute = intent?.hasExplicitStartRoute() == true
when {
!hasExplicitStartRoute && restoredReadBookRoute != null -> {
arrayOf(MainRouteHome, restoredReadBookRoute!!)
@@ -414,6 +415,10 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
)
}
private fun Intent.hasExplicitStartRoute(): Boolean {
return hasExtra(MainIntent.EXTRA_START_ROUTE)
}
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
val keyCode = event.keyCode
val isDown = event.action == KeyEvent.ACTION_DOWN