perf(image): 图片列表默认加载缩略图

This commit is contained in:
yml
2026-11-24 22:30:37 +08:00
parent 3cc61615f9
commit 43df96a973
22 changed files with 227 additions and 85 deletions
@@ -2,7 +2,7 @@
import { computed, ref, watch } from 'vue'
import { EditPen, FullScreen, Pointer } from '@element-plus/icons-vue'
import type { Listing } from '@/features/listings'
import { formatListingCode } from '@/shared/utils/listingDisplay'
import { formatListingCode, getScreenshotThumbURL } from '@/shared/utils/listingDisplay'
interface ReviewScreenshotItem {
url: string
@@ -13,7 +13,6 @@ interface ReviewScreenshotItem {
const props = defineProps<{
visible: boolean
listing: Listing | null
previewUrls: Record<string, string>
}>()
const emit = defineEmits<{
@@ -140,7 +139,12 @@ function handleEdit(shot: ReviewScreenshotItem) {
@click="handleView(index)"
>
<div class="image-wrapper">
<img :src="previewUrls[shot.url] || shot.url" :alt="shot.label" loading="lazy" />
<img
:src="getScreenshotThumbURL(shot.url)"
:alt="shot.label"
loading="lazy"
decoding="async"
/>
<span v-if="isDefaultScreenshot(shot.url)" class="default-badge">默认占位图</span>
<span class="category-tag">{{ shot.label }}</span>
<div class="image-overlay" @click.stop>
@@ -545,6 +545,7 @@ function hasMore(item: ProcessTimelineEvent) {
preview-teleported
fit="cover"
admin
variant="thumb"
image-class="attachment-img"
fallback-class="attachment-fallback"
/>
@@ -307,6 +307,7 @@ function incomeText(income?: number) {
:key="idx"
:source="url"
:admin="true"
variant="thumb"
:preview-src-list="withdrawal.certificate_urls"
fit="cover"
:image-style="{
@@ -351,6 +352,7 @@ function incomeText(income?: number) {
<AuthImage
:source="withdrawal.payment_proof_url"
admin
variant="thumb"
alt="打款凭证"
class="certificate-image"
:preview-src-list="[withdrawal.payment_proof_url]"
@@ -645,6 +645,7 @@ async function handleArbitrate() {
v-if="evidenceKind(item) === 'image'"
:source="evidenceSource(item)"
admin
variant="thumb"
:alt="evidenceName(item, index)"
image-class="evidence-image"
fallback-class="evidence-image-fallback"
@@ -458,6 +458,7 @@ onBeforeUnmount(() => {
<AuthImage
:source="row.image_url"
fit="contain"
variant="thumb"
:image-style="{ width: '64px', height: '64px', background: '#f7f9fc' }"
:preview-src-list="[row.image_url]"
/>
@@ -883,6 +883,8 @@ function accountTypeLabel(type: string) {
:source="createForm.voucher_url"
alt="凭证预览"
class="voucher-img-preview"
variant="thumb"
:preview-src-list="[createForm.voucher_url]"
/>
</div>
</div>
@@ -948,7 +950,13 @@ function accountTypeLabel(type: string) {
<div v-if="selectedManual.voucher_url" class="detail-row column-row">
<span class="detail-label">打款凭证</span>
<div class="detail-img-container">
<AuthImage :source="selectedManual.voucher_url" alt="凭证" class="detail-voucher-img" />
<AuthImage
:source="selectedManual.voucher_url"
alt="凭证"
class="detail-voucher-img"
variant="thumb"
:preview-src-list="[selectedManual.voucher_url]"
/>
</div>
</div>
<div v-if="selectedManual.status === 'voided'" class="void-info-box">
@@ -1028,6 +1028,7 @@ async function openScreenshot(url: string) {
<AuthImage
:source="url"
admin
variant="thumb"
:alt="`资产截图 ${index + 1}`"
image-class="screenshot-image"
fallback-class="screenshot-image"
@@ -54,6 +54,8 @@ import {
getFaceOwnerText,
getListingConsumablePrice,
getListingResources,
getScreenshotMediumURL,
getScreenshotThumbURL,
getOnlineTimeText,
getResourceQuantity,
getSkinNames,
@@ -144,7 +146,6 @@ const filters = reactive({
sortBy: 'default',
})
const previewURLs = reactive<Record<string, string>>({})
const createdObjectURLs = new Set<string>()
const lastRefreshedAt = ref<string>('')
const shortcutsDialogVisible = ref(false)
@@ -249,7 +250,7 @@ watch(
if (!listing) return
selectedID.value = listing.id
await nextTick()
loadScreenshotPreviews(listing)
prepareScreenshotPreviews(listing)
},
{ immediate: true }
)
@@ -260,7 +261,6 @@ onMounted(() => {
})
onBeforeUnmount(() => {
createdObjectURLs.forEach(url => URL.revokeObjectURL(url))
window.removeEventListener('keydown', handleGlobalKeydown)
})
@@ -455,7 +455,7 @@ async function onPriceAdjustSave(payload: {
function openEvidence(row: Listing) {
evidenceListing.value = row
evidenceDialogVisible.value = true
loadScreenshotPreviews(row)
prepareScreenshotPreviews(row)
}
function money(value: number) {
@@ -780,21 +780,9 @@ function extractObjectKey(url: string) {
}
}
async function loadScreenshotPreviews(row: Listing) {
function prepareScreenshotPreviews(row: Listing) {
for (const url of row.screenshot_urls || []) {
if (previewURLs[url]) continue
if (isDefaultScreenshot(url) || !extractObjectKey(url)) {
previewURLs[url] = url
continue
}
try {
const blob = await fetchAdminFileBlob(extractObjectKey(url))
const objectURL = URL.createObjectURL(blob)
createdObjectURLs.add(objectURL)
previewURLs[url] = objectURL
} catch {
previewURLs[url] = url
}
previewURLs[url] = isDefaultScreenshot(url) ? url : getScreenshotMediumURL(url)
}
}
@@ -890,11 +878,6 @@ function openRawScreenshot(url: string) {
window.open(url, '_blank')
return
}
const preview = previewURLs[url]
if (preview) {
window.open(preview, '_blank')
return
}
try {
const key = extractObjectKey(url)
if (!key) {
@@ -952,7 +935,7 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
evidenceListing.value.screenshot_urls = nextUrls
}
await loadScreenshotPreviews(targetListing)
prepareScreenshotPreviews(targetListing)
editorVisible.value = false
editingScreenshot.value = null
}
@@ -1121,13 +1104,10 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
<div class="queue-main-row">
<div class="queue-thumb">
<img
:src="
previewURLs[item.screenshot_urls?.[0] || ''] ||
item.screenshot_urls?.[0] ||
_defaultScreenshotURL
"
:src="getScreenshotThumbURL(item.screenshot_urls?.[0]) || _defaultScreenshotURL"
alt="缩略图"
loading="lazy"
decoding="async"
@error="onThumbError"
/>
<span v-if="hasDefaultScreenshot(item)" class="thumb-warning-badge">默认图</span>
@@ -1611,7 +1591,12 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
@click="handleCardClick(selectedReviewScreenshots, index)"
>
<div class="image-wrapper">
<img :src="previewURLs[shot.url] || shot.url" :alt="shot.label" loading="lazy" />
<img
:src="getScreenshotThumbURL(shot.url)"
:alt="shot.label"
loading="lazy"
decoding="async"
/>
<span v-if="isDefaultScreenshot(shot.url)" class="default-badge">
<el-icon><Warning /></el-icon> 默认占位图
</span>
@@ -1742,7 +1727,6 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
<AdminListingReviewEvidenceDialog
v-model:visible="evidenceDialogVisible"
:listing="evidenceListing"
:preview-urls="previewURLs"
@view-image="openPreviewDialog($event.images, $event.index)"
@peek-image="startPeekPreview($event.images, $event.index)"
@edit-screenshot="openEditor($event.shot, $event.listing)"
@@ -478,6 +478,8 @@ function statusType(status: string): 'success' | 'danger' {
:source="createForm.voucher_url"
alt="凭证预览"
class="voucher-img-preview"
variant="thumb"
:preview-src-list="[createForm.voucher_url]"
/>
</div>
</div>
@@ -545,6 +547,8 @@ function statusType(status: string): 'success' | 'danger' {
:source="selectedExpense.voucher_url"
alt="凭证"
class="detail-voucher-img"
variant="thumb"
:preview-src-list="[selectedExpense.voucher_url]"
/>
</div>
</div>
@@ -696,6 +696,7 @@ onMounted(reloadAll)
<AuthImage
:source="row.image_url"
fit="cover"
variant="thumb"
:image-style="{ width: '56px', height: '56px', borderRadius: '6px' }"
:preview-src-list="[row.image_url]"
/>
@@ -837,6 +838,7 @@ onMounted(reloadAll)
v-if="img.url"
:source="img.url"
fit="cover"
variant="thumb"
:image-style="{ width: '52px', height: '52px', borderRadius: '6px' }"
:preview-src-list="[img.url]"
/>
@@ -910,6 +912,7 @@ onMounted(reloadAll)
v-if="editForm.image_url"
:source="editForm.image_url"
fit="cover"
variant="thumb"
:preview-src-list="[editForm.image_url]"
:image-style="{ width: '100%', height: '100%', borderRadius: '6px' }"
/>
@@ -255,6 +255,7 @@ const hasContent = computed(() => Boolean(snapshot.value))
<AuthImage
:source="shot.url"
:alt="shot.label"
variant="thumb"
image-class="shot-img"
fit="cover"
:preview-src-list="screenshotUrls"
@@ -314,6 +315,7 @@ const hasContent = computed(() => Boolean(snapshot.value))
<AuthImage
:source="shot.url"
:alt="shot.label"
variant="thumb"
image-class="shot-img"
fit="cover"
:preview-src-list="screenshotUrls"
@@ -253,6 +253,7 @@ async function handleOffline() {
<AuthImage
:source="detailScreenshots[0].url"
:alt="getListingTitle(listing)"
variant="thumb"
image-class="cover-img"
fit="cover"
:preview-src-list="detailScreenshotUrls"
@@ -333,6 +334,7 @@ async function handleOffline() {
<AuthImage
:source="shot.url"
:alt="shot.label"
variant="thumb"
image-class="shot-img"
fit="cover"
:preview-src-list="detailScreenshotUrls"
@@ -335,6 +335,7 @@ async function handleOffline() {
<AuthImage
:source="shot.url"
:alt="shot.label"
variant="thumb"
image-class="shot-img"
fit="cover"
:preview-src-list="detailScreenshotUrls"
@@ -260,6 +260,7 @@ function removeImage(index: number) {
:source="url"
alt="凭证"
fit="cover"
variant="thumb"
:preview-src-list="form.certificate_urls"
:preview-initial-index="index"
/>
@@ -633,6 +633,7 @@ function statusType(status: string): 'primary' | 'success' | 'danger' | 'warning
:source="url"
alt="收款凭证"
fit="cover"
variant="thumb"
:preview-src-list="accountForm.certificate_urls"
:preview-initial-index="index"
/>