diff --git a/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/web/OnlineNennungFormular.kt b/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/web/OnlineNennungFormular.kt index ded037c3..cf507655 100644 --- a/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/web/OnlineNennungFormular.kt +++ b/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/web/OnlineNennungFormular.kt @@ -222,11 +222,11 @@ fun OnlineNennungFormular( modifier = Modifier.padding(bottom = 4.dp) ) Text( - text = "v2026-04-23.5 - RADICAL RELOAD", // Eindeutige Version für diesen Fix + text = "v2026-04-23.7 - URL-ROUTING", // Version erhöht für URL-Routing Fix style = MaterialTheme.typography.labelLarge, fontWeight = FontWeight.Bold, - color = Color.Red, - modifier = Modifier.padding(bottom = 4.dp).background(Color.Yellow.copy(alpha = 0.3f)) + color = Color.Blue, // Farbe geändert für neue Version + modifier = Modifier.padding(bottom = 4.dp).background(Color.Black.copy(alpha = 0.05f)) ) } diff --git a/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt b/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt index ad4ba5fc..8a141663 100644 --- a/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt +++ b/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt @@ -26,6 +26,15 @@ fun WebMainScreen() { MainAppContent() } +@OptIn(ExperimentalWasmJsInterop::class) +private fun getWindowHash(): String = js("window.location.hash") + +@OptIn(ExperimentalWasmJsInterop::class) +private fun setWindowHash(hash: String): Unit = js("window.location.hash = hash") + +@OptIn(ExperimentalWasmJsInterop::class) +private fun onHashChange(onChanged: () -> Unit): Unit = js("window.addEventListener('hashchange', onChanged)") + @OptIn(ExperimentalMaterial3Api::class) @Composable fun MainAppContent() { @@ -34,6 +43,32 @@ fun MainAppContent() { val scope = rememberCoroutineScope() var currentScreen by remember { mutableStateOf(WebScreen.Landing) } + // Hash-basiertes Routing zur Synchronisation mit der Adressleiste + LaunchedEffect(Unit) { + val handleHashChange = { + val hash = getWindowHash() + currentScreen = when { + hash.startsWith("#/nennung/") -> { + val tId = hash.substringAfter("#/nennung/").toLongOrNull() ?: 26128L + WebScreen.Nennung(1, tId) + } + else -> WebScreen.Landing + } + } + handleHashChange() + onHashChange { handleHashChange() } + } + + // Update der Adressleiste bei Screen-Wechsel + LaunchedEffect(currentScreen) { + val targetHash = when (val screen = currentScreen) { + is WebScreen.Landing -> "/" + is WebScreen.Nennung -> "/nennung/${screen.turnierId}" + is WebScreen.Erfolg -> "/erfolg" + } + setWindowHash("#$targetHash") + } + Scaffold( topBar = { TopAppBar( diff --git a/frontend/shells/meldestelle-web/src/wasmJsMain/resources/index.html b/frontend/shells/meldestelle-web/src/wasmJsMain/resources/index.html index 68bcf91b..fc19227a 100644 --- a/frontend/shells/meldestelle-web/src/wasmJsMain/resources/index.html +++ b/frontend/shells/meldestelle-web/src/wasmJsMain/resources/index.html @@ -19,6 +19,13 @@ height: 100%; } +