From a388fb2f5f47a175ff27ca2af41421ad4e7dde5d Mon Sep 17 00:00:00 2001 From: rene Date: Mon, 8 Jun 2026 06:29:04 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Seiten-Hash-Links=20()=20navigieren=20jetzt=20=E2=80=94=20Router=20hatte=20keinen?= =?UTF-8?q?=20hashchange-Listener?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rene: gleiche URL #partner, anderer Inhalt — Nav-Button (data-page→navigate) schaltete um, der -Link nicht. Ursache: Router reagierte nur auf [data-page]-Klicks + App.navigate(), nie auf echte hashchange-Events. Plain Hash-Links änderten die URL ohne Seitenwechsel (Default blieb 'diary'). Globaler hashchange-Listener ergänzt (gleiches Hash-Parsing wie init, inkl. ?-Params); pushState in navigate() feuert kein hashchange → keine Schleife; replaceState schreibt {page} in die History, damit Back/Forward die Seite kennt. Repariert app-weit ALLE Seiten-Hash-Links (#settings, #agb, #litters, #partner, #partner-dashboard), nicht nur den neuen Gründer→Partner-Link. --- VERSION | 2 +- backend/static/index.html | 24 ++++++++++++------------ backend/static/js/app.js | 19 ++++++++++++++++--- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 3720c6f..1ab8b27 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1272 \ No newline at end of file +1273 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index e45df41..0688cd4 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -620,11 +620,11 @@ - - - - - + + + + + @@ -634,7 +634,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index c9ee7fa..b6070bc 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1272'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1273'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; @@ -585,8 +585,21 @@ const App = (() => { navigate(page, false); }); - // Hash-Navigation wird in init() nach _checkAuth() behandelt (nicht hier), - // damit kein doppelter _loadPage()-Aufruf entsteht. + // Hash-Navigation: plain ändert nur die URL (kein data-page, + // kein App.navigate). Ohne diesen Listener bliebe die Seite stehen / zeigte den + // Default 'diary' bei gleicher URL. pushState (in navigate) feuert KEIN hashchange + // → keine Schleife; der Listener greift nur bei echten Hash-Klicks/Edits. + window.addEventListener('hashchange', () => { + const [page, query] = location.hash.replace('#', '').split('?'); + if (!page || !pages[page] || page === state.page) return; + const params = {}; + if (query) new URLSearchParams(query).forEach((v, k) => { params[k] = isNaN(v) ? v : Number(v); }); + _closeSidebar(); + navigate(page, false, params); // Hash steht schon + history.replaceState({ page }, '', location.hash); // damit Back/Forward die Seite kennt + }); + + // Hash-Navigation beim Erststart wird in init() nach _checkAuth() behandelt. } // ---------------------------------------------------------- diff --git a/backend/static/landing.html b/backend/static/landing.html index 3045c5e..02ee9f7 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 2062953..794d97c 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1272'; +const VER = '1273'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten