feat: als pwa installierbar

- Manifest 'LAN-Clipboard' / 'Clipboard', standalone, eigene Icons (auch maskable)
- iOS: apple-touch-icon, Web-App-Metadaten, Statusleiste black-translucent
- Service Worker (vite-plugin-pwa) cacht nur die App-Hülle, nie /api
- Hinweis 'Neue Version verfügbar' mit Neu laden
- Offline-Seite, wenn beim Start kein Server erreichbar ist
- Icons per scripts/render-icons.sh aus SVG gerendert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dbildhauerandClaude Opus 5.5 committed 2026-10-25 11:46:17 +01:00
1 parent 998e86c84f
commit 0ad6d248cf
20 files changed
+5180 -6

No files matched your search

+2
View File
@@ -3,6 +3,7 @@ import { watch } from 'vue'
import { RouterView } from 'vue-router'
import AppHeader from '@/components/AppHeader.vue'
import UpdateBanner from '@/components/UpdateBanner.vue'
import { useAuthStore } from '@/stores/auth'
import { useClipsStore } from '@/stores/clips'
import { useSyncStore } from '@/stores/sync'
@@ -28,4 +29,5 @@ watch(
<template>
<AppHeader v-if="auth.user" />
<RouterView />
<UpdateBanner />
</template>
+29
View File
@@ -0,0 +1,29 @@
<script setup lang="ts">
import { applyUpdate, updateAvailable } from '@/pwa'
</script>
<template>
<div v-if="updateAvailable" class="update-banner" role="status">
<span>Neue Version verfügbar</span>
<button type="button" class="primary small" @click="applyUpdate">Neu laden</button>
</div>
</template>
<style scoped>
.update-banner {
position: fixed;
left: 50%;
bottom: calc(1rem + env(safe-area-inset-bottom));
z-index: 20;
display: flex;
align-items: center;
gap: 1rem;
padding: 0.5rem 0.5rem 0.5rem 1rem;
transform: translateX(-50%);
background: var(--surface);
border: 1px solid var(--accent);
border-radius: var(--radius);
box-shadow: 0 4px 16px rgb(0 0 0 / 40%);
white-space: nowrap;
}
</style>
+2
View File
@@ -6,6 +6,7 @@ import { createApp } from 'vue'
import { setUnauthorizedHandler } from './api/client'
import App from './App.vue'
import { initPwa } from './pwa'
import router from './router'
import { useAuthStore } from './stores/auth'
@@ -23,3 +24,4 @@ setUnauthorizedHandler(() => {
})
app.mount('#app')
initPwa()
+20
View File
@@ -0,0 +1,20 @@
import { ref } from 'vue'
import { registerSW } from 'virtual:pwa-register'
/** True when a new version has been downloaded and waits for the user to reload. */
export const updateAvailable = ref(false)
let updateServiceWorker: ((reload?: boolean) => Promise<void>) | undefined
export function initPwa(): void {
if (!('serviceWorker' in navigator)) return
updateServiceWorker = registerSW({
onNeedRefresh() {
updateAvailable.value = true
},
})
}
export function applyUpdate(): void {
void updateServiceWorker?.(true)
}
+13 -1
View File
@@ -1,5 +1,6 @@
import { createRouter, createWebHistory } from 'vue-router'
import { ApiError } from '@/api/client'
import { useAuthStore } from '@/stores/auth'
import HomeView from '@/views/HomeView.vue'
@@ -33,13 +34,24 @@ const router = createRouter({
component: () => import('@/views/AdminUsersView.vue'),
meta: { admin: true },
},
{
path: '/offline',
name: 'offline',
component: () => import('@/views/OfflineView.vue'),
meta: { public: true },
},
{ path: '/:pathMatch(.*)*', redirect: '/' },
],
})
router.beforeEach(async (to) => {
const auth = useAuthStore()
await auth.ensureLoaded()
try {
await auth.ensureLoaded()
} catch (e) {
// Network failure (not an HTTP error): the app shell came from the service worker cache
if (!(e instanceof ApiError) && to.name !== 'offline') return { name: 'offline' }
}
if (to.meta.public) {
return auth.user && to.name === 'login' ? { name: 'home' } : true
+2 -2
View File
@@ -13,10 +13,10 @@ export const useAuthStore = defineStore('auth', () => {
async function fetchMe(): Promise<void> {
try {
user.value = await api.get<User>('/auth/me')
loaded.value = true
} catch (e) {
if (!(e instanceof ApiError) || e.status !== 401) throw e
if (!(e instanceof ApiError) || e.status !== 401) throw e // retry on next navigation
user.value = null
} finally {
loaded.value = true
}
}
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
function retry(): void {
window.location.assign('/')
}
</script>
<template>
<main class="offline">
<h1>Keine Verbindung</h1>
<p class="muted">
Der Server ist gerade nicht erreichbar. Clips werden aus Datenschutzgründen nicht auf dem
Gerät gespeichert und sind daher nur online verfügbar.
</p>
<button type="button" class="primary" @click="retry">Erneut versuchen</button>
</main>
</template>
<style scoped>
.offline {
max-width: 28rem;
margin: 0 auto;
padding: 20vh 1rem 2rem;
text-align: center;
}
</style>