更新缩略图

This commit is contained in:
2026-07-03 00:15:41 +08:00
parent 7bb0531c4b
commit 273892f98f
15 changed files with 416 additions and 61 deletions
+9 -4
View File
@@ -1,9 +1,9 @@
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
import { api } from '../api'
import { fmtTs, fmtDate, fmtClock } from '../utils/format'
import { copyText } from '../utils/clipboard'
import { generatedUrl } from '../api'
import { generatedUrl, thumbUrl } from '../api'
import Icon from '../components/Icon.vue'
import MediaLightbox from '../components/MediaLightbox.vue'
@@ -107,6 +107,10 @@ function fmtWhen(ts) {
return fmtTs(ts)
}
// Video rows whose first-frame thumbnail is missing (old videos) — fall back
// to the muted <video> preview for those.
const thumbFail = reactive({})
const previewing = ref(null) // entry whose generated file is open in the lightbox
function openPreview(e) {
// API (v1) outputs aren't persisted/served by us (image=b64 inline, video=an
@@ -251,8 +255,9 @@ const sourcePill = (s) => ({
<button v-if="e.status === 'success' && e.file && e.source !== 'v1'"
@click="openPreview(e)"
class="block w-12 h-12 mx-auto rounded-lg overflow-hidden ring-1 ring-white/10 hover:ring-fuchsia-400/60 transition-all">
<img v-if="e.kind !== 'video'" :src="generatedUrl(e.file)" loading="lazy"
class="w-full h-full object-cover" />
<img v-if="e.kind !== 'video' || !thumbFail[e.id]" :src="thumbUrl(e.file)" loading="lazy"
class="w-full h-full object-cover"
@error="e.kind === 'video' && (thumbFail[e.id] = true)" />
<video v-else :src="generatedUrl(e.file)" muted loop preload="metadata" playsinline
class="w-full h-full object-cover"
@mouseenter="$event.target.play && $event.target.play()"