feat: clip-liste mit schnell-eingabe und kopieren
- Startseite zeigt Clips, angeheftete zuerst, mit 'Weitere laden' - Schnell-Eingabe mit Text/Code, Spracherkennung und Einfügen aus der Zwischenablage - Kopieren-Button mit Clipboard API und Ausweichlösung - Syntax-Highlighting mit highlight.js (nur die 24 unterstützten Sprachen) - Pinia-Store für Clips als Grundlage für den Live-Sync Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4caab7e657
commit
7b16940b96
13 files changed
+673
-42
No files matched your search
@@ -1,48 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useHealthStore } from '@/stores/health'
|
||||
import type { Clip } from '@/api/types'
|
||||
import ClipCard from '@/components/ClipCard.vue'
|
||||
import QuickAdd from '@/components/QuickAdd.vue'
|
||||
import { useClipsStore } from '@/stores/clips'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const store = useHealthStore()
|
||||
const store = useClipsStore()
|
||||
|
||||
onMounted(store.refresh)
|
||||
async function togglePin(clip: Clip): Promise<void> {
|
||||
try {
|
||||
await store.update(clip.id, { pinned: !clip.pinned })
|
||||
} catch (e) {
|
||||
store.error = e instanceof Error ? e.message : String(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(clip: Clip): Promise<void> {
|
||||
if (!confirm('Diesen Clip endgültig löschen?')) return
|
||||
try {
|
||||
await store.remove(clip.id)
|
||||
} catch (e) {
|
||||
store.error = e instanceof Error ? e.message : String(e)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(store.load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<h1>Hallo {{ auth.user?.username }}</h1>
|
||||
<section class="card">
|
||||
<h2>Systemstatus</h2>
|
||||
<p v-if="store.loading" class="muted">Prüfe …</p>
|
||||
<p v-else-if="store.error" class="error">Backend nicht erreichbar: {{ store.error }}</p>
|
||||
<dl v-else-if="store.health">
|
||||
<dt>Status</dt>
|
||||
<dd :class="store.health.status">{{ store.health.status }}</dd>
|
||||
<dt>Datenbank</dt>
|
||||
<dd :class="store.health.db">{{ store.health.db }}</dd>
|
||||
<dt>Version</dt>
|
||||
<dd>{{ store.health.version }}</dd>
|
||||
</dl>
|
||||
<button type="button" :disabled="store.loading" @click="store.refresh">Aktualisieren</button>
|
||||
</section>
|
||||
<QuickAdd />
|
||||
|
||||
<p v-if="store.error" class="error" role="alert">{{ store.error }}</p>
|
||||
<p v-if="store.loading && store.items.length === 0" class="muted">Lade …</p>
|
||||
<p v-else-if="!store.loading && store.items.length === 0" class="muted empty">
|
||||
Noch keine Clips. Füge oben Text oder Code ein.
|
||||
</p>
|
||||
|
||||
<ClipCard
|
||||
v-for="clip in store.items"
|
||||
:key="clip.id"
|
||||
:clip="clip"
|
||||
@toggle-pin="togglePin(clip)"
|
||||
@remove="remove(clip)"
|
||||
/>
|
||||
|
||||
<button
|
||||
v-if="store.items.length < store.total"
|
||||
type="button"
|
||||
class="more"
|
||||
@click="store.loadMore"
|
||||
>
|
||||
Weitere laden ({{ store.total - store.items.length }})
|
||||
</button>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
dl {
|
||||
display: grid;
|
||||
grid-template-columns: max-content 1fr;
|
||||
gap: 0.25rem 1rem;
|
||||
margin: 0 0 1rem;
|
||||
.empty {
|
||||
text-align: center;
|
||||
padding: 2rem 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
.more {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user