fix: harden offline fallback and track visitable pages
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 1m36s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 1m36s
This commit is contained in:
@@ -5,75 +5,392 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Hors ligne - StripStream</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #020817;
|
||||
--panel: rgba(2, 8, 23, 0.66);
|
||||
--panel-strong: rgba(2, 8, 23, 0.82);
|
||||
--line: rgba(99, 102, 241, 0.3);
|
||||
--text: #f1f5f9;
|
||||
--muted: #cbd5e1;
|
||||
--primary: #4f46e5;
|
||||
--primary-2: #06b6d4;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
sans-serif;
|
||||
background-color: #0f172a;
|
||||
color: #e2e8f0;
|
||||
font-family: "Segoe UI", "SF Pro Text", -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(2, 8, 23, 0.99) 0%, rgba(2, 8, 23, 0.94) 42%, #020817 100%),
|
||||
radial-gradient(70% 45% at 12% 0%, rgba(79, 70, 229, 0.16), transparent 62%),
|
||||
radial-gradient(58% 38% at 88% 8%, rgba(6, 182, 212, 0.14), transparent 65%),
|
||||
radial-gradient(50% 34% at 50% 100%, rgba(236, 72, 153, 0.1), transparent 70%),
|
||||
repeating-linear-gradient(0deg, rgba(226, 232, 240, 0.02) 0 1px, transparent 1px 24px),
|
||||
repeating-linear-gradient(90deg, rgba(226, 232, 240, 0.015) 0 1px, transparent 1px 30px);
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 30;
|
||||
height: 64px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: rgba(2, 8, 23, 0.7);
|
||||
backdrop-filter: blur(12px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background:
|
||||
linear-gradient(112deg, rgba(79, 70, 229, 0.24) 0%, rgba(6, 182, 212, 0.2) 30%, transparent 56%),
|
||||
linear-gradient(248deg, rgba(244, 114, 182, 0.16) 0%, transparent 46%),
|
||||
repeating-linear-gradient(135deg, rgba(226, 232, 240, 0.03) 0 1px, transparent 1px 11px);
|
||||
}
|
||||
|
||||
.header-inner {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0 1rem;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.menu-btn {
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.35);
|
||||
background: rgba(15, 23, 42, 0.6);
|
||||
color: var(--text);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.brand-title {
|
||||
font-size: 1.05rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
background: linear-gradient(90deg, var(--primary), var(--primary-2), #d946ef);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.brand-subtitle {
|
||||
font-size: 0.6rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.25em;
|
||||
color: rgba(226, 232, 240, 0.75);
|
||||
margin-top: 0.2rem;
|
||||
}
|
||||
|
||||
.pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.35);
|
||||
background: rgba(2, 8, 23, 0.55);
|
||||
color: var(--muted);
|
||||
padding: 0.45rem 0.7rem;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.layout {
|
||||
position: relative;
|
||||
min-height: calc(100vh - 64px);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 280px;
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.25s ease;
|
||||
border-right: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
backdrop-filter: blur(12px);
|
||||
padding: 1rem;
|
||||
overflow: hidden;
|
||||
z-index: 35;
|
||||
}
|
||||
|
||||
.sidebar-open .sidebar {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.sidebar-overlay {
|
||||
position: fixed;
|
||||
inset: 64px 0 0 0;
|
||||
background: rgba(2, 6, 23, 0.48);
|
||||
backdrop-filter: blur(1px);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.2s ease;
|
||||
z-index: 32;
|
||||
}
|
||||
|
||||
.sidebar-open .sidebar-overlay {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.sidebar::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background:
|
||||
linear-gradient(160deg, rgba(79, 70, 229, 0.12) 0%, rgba(6, 182, 212, 0.08) 32%, transparent 58%),
|
||||
linear-gradient(332deg, rgba(244, 114, 182, 0.06) 0%, transparent 42%),
|
||||
repeating-linear-gradient(135deg, rgba(226, 232, 240, 0.02) 0 1px, transparent 1px 11px);
|
||||
}
|
||||
|
||||
.sidebar-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.section {
|
||||
border: 1px solid rgba(148, 163, 184, 0.25);
|
||||
background: rgba(2, 8, 23, 0.45);
|
||||
border-radius: 0.9rem;
|
||||
padding: 0.7rem;
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
margin: 0.25rem 0.45rem 0.6rem;
|
||||
font-size: 0.67rem;
|
||||
letter-spacing: 0.2em;
|
||||
text-transform: uppercase;
|
||||
color: rgba(148, 163, 184, 0.95);
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.65rem;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
text-align: left;
|
||||
padding: 0.62rem 0.78rem;
|
||||
margin: 0.14rem 0;
|
||||
font-size: 0.93rem;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: rgba(148, 163, 184, 0.08);
|
||||
}
|
||||
|
||||
.nav-link.active {
|
||||
border-color: rgba(79, 70, 229, 0.45);
|
||||
background: rgba(79, 70, 229, 0.16);
|
||||
}
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
padding: 2rem;
|
||||
min-height: calc(100vh - 64px);
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
|
||||
.card {
|
||||
width: min(720px, 100%);
|
||||
border: 1px solid rgba(148, 163, 184, 0.3);
|
||||
border-radius: 1rem;
|
||||
background: var(--panel-strong);
|
||||
box-shadow: 0 25px 60px -35px rgba(2, 6, 23, 0.92);
|
||||
padding: 1.5rem;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
|
||||
.status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
color: #fecaca;
|
||||
background: rgba(127, 29, 29, 0.3);
|
||||
border: 1px solid rgba(248, 113, 113, 0.35);
|
||||
border-radius: 999px;
|
||||
padding: 0.35rem 0.7rem;
|
||||
font-size: 0.82rem;
|
||||
margin-bottom: 1rem;
|
||||
color: #4f46e5;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 0.7rem;
|
||||
font-size: clamp(1.35rem, 2.4vw, 1.95rem);
|
||||
line-height: 1.24;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.5;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 2rem;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
.buttons {
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
gap: 0.7rem;
|
||||
margin-top: 1.35rem;
|
||||
}
|
||||
button {
|
||||
background-color: #4f46e5;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 1rem;
|
||||
|
||||
.btn {
|
||||
appearance: none;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.65rem;
|
||||
padding: 0.7rem 1rem;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #4338ca;
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
}
|
||||
button.secondary {
|
||||
background-color: #475569;
|
||||
|
||||
.btn-secondary {
|
||||
background: rgba(2, 8, 23, 0.45);
|
||||
border-color: rgba(148, 163, 184, 0.35);
|
||||
color: var(--text);
|
||||
}
|
||||
button.secondary:hover {
|
||||
background-color: #334155;
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: rgba(30, 41, 59, 0.65);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #4338ca;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 1rem;
|
||||
font-size: 0.82rem;
|
||||
color: rgba(148, 163, 184, 0.95);
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 1.2rem;
|
||||
padding-top: 0.85rem;
|
||||
border-top: 1px dashed rgba(148, 163, 184, 0.28);
|
||||
font-size: 0.8rem;
|
||||
color: rgba(148, 163, 184, 0.88);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.main {
|
||||
min-height: calc(100vh - 64px);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Vous êtes hors ligne</h1>
|
||||
<p>
|
||||
Il semble que vous n'ayez pas de connexion internet. Certaines fonctionnalités de
|
||||
StripStream peuvent ne pas être disponibles en mode hors ligne.
|
||||
</p>
|
||||
<div class="buttons">
|
||||
<button class="secondary" onclick="window.history.back()">Retour</button>
|
||||
<button onclick="window.location.reload()">Réessayer</button>
|
||||
<header class="header">
|
||||
<div class="header-inner">
|
||||
<div class="brand">
|
||||
<button class="menu-btn" id="sidebar-toggle" type="button" aria-label="Menu">☰</button>
|
||||
<div>
|
||||
<div class="brand-title">STRIPSTREAM</div>
|
||||
<div class="brand-subtitle">comic reader</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="pill">Mode hors ligne</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="layout">
|
||||
<button class="sidebar-overlay" id="sidebar-overlay" aria-label="Fermer le menu"></button>
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-content">
|
||||
<div class="section">
|
||||
<h2>Navigation</h2>
|
||||
<button class="nav-link active" type="button">Accueil</button>
|
||||
<button class="nav-link" type="button">Telechargements</button>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2>Compte</h2>
|
||||
<button class="nav-link" type="button">Mon compte</button>
|
||||
<button class="nav-link" type="button">Preferences</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="main">
|
||||
<div class="card">
|
||||
<div class="status">● Hors ligne</div>
|
||||
<h1>Cette page n'est pas encore disponible hors ligne.</h1>
|
||||
<p>
|
||||
Tu peux continuer a naviguer sur les pages deja consultees. Cette route sera
|
||||
disponible hors ligne apres une visite en ligne.
|
||||
</p>
|
||||
<div class="actions">
|
||||
<button class="btn btn-secondary" onclick="window.history.back()">Retour</button>
|
||||
<button class="btn btn-primary" onclick="window.location.reload()">Reessayer</button>
|
||||
</div>
|
||||
<div class="hint">
|
||||
Astuce: visite d'abord Accueil, Bibliotheques, Series et pages de lecture quand tu es
|
||||
en ligne.
|
||||
</div>
|
||||
<div class="footer">StripStream - interface hors ligne</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const toggle = document.getElementById("sidebar-toggle");
|
||||
const overlay = document.getElementById("sidebar-overlay");
|
||||
|
||||
if (toggle && overlay) {
|
||||
toggle.addEventListener("click", () => {
|
||||
document.body.classList.toggle("sidebar-open");
|
||||
});
|
||||
|
||||
overlay.addEventListener("click", () => {
|
||||
document.body.classList.remove("sidebar-open");
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("online", () => {
|
||||
window.location.reload();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
212
public/sw.js
212
public/sw.js
File diff suppressed because one or more lines are too long
@@ -36,6 +36,7 @@ interface CacheStats {
|
||||
images: { size: number; entries: number };
|
||||
books: { size: number; entries: number };
|
||||
total: number;
|
||||
visitablePages: number;
|
||||
}
|
||||
|
||||
interface CacheEntry {
|
||||
@@ -376,6 +377,9 @@ export function CacheSettings() {
|
||||
<p className="text-xs text-muted-foreground text-right">
|
||||
{t("settings.cache.imagesQuota", { used: Math.round(usagePercent) })}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t("settings.cache.visitablePages", { count: stats.visitablePages })}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ interface CacheStats {
|
||||
images: { size: number; entries: number };
|
||||
books: { size: number; entries: number };
|
||||
total: number;
|
||||
visitablePages: number;
|
||||
}
|
||||
|
||||
interface CacheEntry {
|
||||
@@ -112,7 +113,12 @@ export function ServiceWorkerProvider({ children }: { children: ReactNode }) {
|
||||
case "CACHE_STATS":
|
||||
const statsResolver = pendingRequests.current.get("CACHE_STATS");
|
||||
if (statsResolver) {
|
||||
statsResolver(payload);
|
||||
const normalizedPayload = {
|
||||
...payload,
|
||||
visitablePages:
|
||||
typeof payload?.visitablePages === "number" ? payload.visitablePages : 0,
|
||||
};
|
||||
statsResolver(normalizedPayload);
|
||||
pendingRequests.current.delete("CACHE_STATS");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -144,10 +144,11 @@
|
||||
"initializing": "Initializing...",
|
||||
"totalStorage": "Total storage",
|
||||
"imagesQuota": "{used}% of images quota used",
|
||||
"visitablePages": "{count} pages available offline",
|
||||
"static": "Static resources",
|
||||
"staticDesc": "Next.js scripts, styles and assets",
|
||||
"pages": "Visited pages",
|
||||
"pagesDesc": "Home, libraries, series and details",
|
||||
"pagesDesc": "Pages and navigation data available offline",
|
||||
"api": "API data",
|
||||
"apiDesc": "Series, books and library metadata",
|
||||
"images": "Images",
|
||||
|
||||
@@ -144,10 +144,11 @@
|
||||
"initializing": "Initialisation...",
|
||||
"totalStorage": "Stockage total",
|
||||
"imagesQuota": "{used}% du quota images utilisé",
|
||||
"visitablePages": "{count} pages visitables hors ligne",
|
||||
"static": "Ressources statiques",
|
||||
"staticDesc": "Scripts, styles et assets Next.js",
|
||||
"pages": "Pages visitées",
|
||||
"pagesDesc": "Home, bibliothèques, séries et détails",
|
||||
"pagesDesc": "Pages et données de navigation disponibles hors ligne",
|
||||
"api": "Données API",
|
||||
"apiDesc": "Métadonnées des séries, livres et bibliothèques",
|
||||
"images": "Images",
|
||||
|
||||
Reference in New Issue
Block a user