Fix: Offline-UX — 📡 statt 🚧 bei offline-Seiten, schnellerer Warm-up, mehr Endpoints gecacht (SW by-v989)
This commit is contained in:
parent
8ad3ca8a74
commit
f0c1ee3386
4 changed files with 26 additions and 16 deletions
|
|
@ -410,7 +410,7 @@ async def serve_media(path: str, request: _Request):
|
||||||
raise _HE(404, "Nicht gefunden.")
|
raise _HE(404, "Nicht gefunden.")
|
||||||
return _media_response(filepath)
|
return _media_response(filepath)
|
||||||
|
|
||||||
APP_VER = "988" # muss mit APP_VER in app.js übereinstimmen
|
APP_VER = "989" # muss mit APP_VER in app.js übereinstimmen
|
||||||
|
|
||||||
@app.get("/.well-known/assetlinks.json")
|
@app.get("/.well-known/assetlinks.json")
|
||||||
async def assetlinks():
|
async def assetlinks():
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '988'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '989'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||||
|
|
@ -266,10 +266,13 @@ const App = (() => {
|
||||||
page.module = {}; // verhindert erneutes Laden
|
page.module = {}; // verhindert erneutes Laden
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
const _offline = !navigator.onLine;
|
||||||
container.innerHTML = UI.emptyState({
|
container.innerHTML = UI.emptyState({
|
||||||
icon: '🚧',
|
icon: _offline ? '📡' : '🚧',
|
||||||
title: pages[pageId].title,
|
title: pages[pageId].title,
|
||||||
text: 'Diese Seite ist noch in Entwicklung.',
|
text: _offline
|
||||||
|
? 'Diese Seite ist offline nicht verfügbar. Bitte öffne sie einmal mit Internetverbindung, damit sie gecacht wird.'
|
||||||
|
: 'Diese Seite ist noch in Entwicklung.',
|
||||||
});
|
});
|
||||||
page.module = {};
|
page.module = {};
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -1141,17 +1144,19 @@ const App = (() => {
|
||||||
window.App = App; // Worlds kann App.navigate() aufrufen
|
window.App = App; // Worlds kann App.navigate() aufrufen
|
||||||
|
|
||||||
// App starten
|
// App starten
|
||||||
// Prioritäts-Seiten im Hintergrund vorladen (3s nach Start, damit Hauptinhalt nicht blockiert)
|
// Prioritäts-Seiten im Hintergrund vorladen (1s nach Start)
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!('caches' in window)) return;
|
if (!navigator.onLine) return;
|
||||||
['admin','erste-hilfe','diary','map','walks','routes','poison','lost'].forEach(page => {
|
// Page-Scripts cachen
|
||||||
|
[
|
||||||
|
'admin','erste-hilfe','diary','map','walks','routes','poison','lost',
|
||||||
|
'expenses','wetter','forum','health','uebungen','trainingsplaene','notes',
|
||||||
|
].forEach(page => {
|
||||||
const key = `Page_${page.replace(/-/g,'_')}`;
|
const key = `Page_${page.replace(/-/g,'_')}`;
|
||||||
if (!window[key]) {
|
if (!window[key]) fetch(`/js/pages/${page}.js?v=${APP_VER}`).catch(() => {});
|
||||||
fetch(`/js/pages/${page}.js?v=${APP_VER}`).catch(() => {});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,8 @@ window.Page_routes = (() => {
|
||||||
if (!_appState.user) { UI.toast.warning('Bitte anmelden.'); return; }
|
if (!_appState.user) { UI.toast.warning('Bitte anmelden.'); return; }
|
||||||
if (_recOvl) return;
|
if (_recOvl) return;
|
||||||
|
|
||||||
await UI.loadLeaflet?.() ?? Promise.resolve();
|
try { await (UI.loadLeaflet?.() ?? Promise.resolve()); }
|
||||||
|
catch { UI.toast.warning('Karte offline nicht verfügbar — GPS-Aufzeichnung läuft trotzdem.'); }
|
||||||
|
|
||||||
const ovl = document.createElement('div');
|
const ovl = document.createElement('div');
|
||||||
ovl.id = 'rk-rec-ovl';
|
ovl.id = 'rk-rec-ovl';
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v988';
|
const CACHE_VERSION = 'by-v989';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||||
|
|
@ -140,10 +140,14 @@ const _CACHEABLE_GET = [
|
||||||
/^\/api\/training\/plan-progress/,
|
/^\/api\/training\/plan-progress/,
|
||||||
/^\/api\/wiki\/rassen/,
|
/^\/api\/wiki\/rassen/,
|
||||||
/^\/api\/dogs\/\d+\/diary\/stats/,
|
/^\/api\/dogs\/\d+\/diary\/stats/,
|
||||||
/^\/api\/routes$/,
|
/^\/api\/routes/,
|
||||||
/^\/api\/places$/,
|
/^\/api\/places/,
|
||||||
/^\/api\/breeder\/map-markers$/,
|
/^\/api\/breeder\/map-markers/,
|
||||||
/^\/api\/gassi-zeiten/,
|
/^\/api\/gassi-zeiten/,
|
||||||
|
/^\/api\/poison/,
|
||||||
|
/^\/api\/walks/,
|
||||||
|
/^\/api\/lost/,
|
||||||
|
/^\/api\/expenses/,
|
||||||
// Drei Welten — offline-fähig
|
// Drei Welten — offline-fähig
|
||||||
/^\/api\/streak\/\d+/,
|
/^\/api\/streak\/\d+/,
|
||||||
/^\/api\/forum\/threads/,
|
/^\/api\/forum\/threads/,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue