fix(image): 修复审核图片鉴权加载

This commit is contained in:
yml
2026-11-24 22:43:59 +08:00
parent 43df96a973
commit 4c7271bcb7
3 changed files with 24 additions and 48 deletions
@@ -2,7 +2,8 @@
import { computed, ref, watch } from 'vue'
import { EditPen, FullScreen, Pointer } from '@element-plus/icons-vue'
import type { Listing } from '@/features/listings'
import { formatListingCode, getScreenshotThumbURL } from '@/shared/utils/listingDisplay'
import AuthImage from '@/shared/components/business/AuthImage.vue'
import { formatListingCode } from '@/shared/utils/listingDisplay'
interface ReviewScreenshotItem {
url: string
@@ -139,11 +140,12 @@ function handleEdit(shot: ReviewScreenshotItem) {
@click="handleView(index)"
>
<div class="image-wrapper">
<img
:src="getScreenshotThumbURL(shot.url)"
<AuthImage
:source="shot.url"
:alt="shot.label"
loading="lazy"
decoding="async"
variant="thumb"
image-class="evidence-thumb-image"
fallback-class="evidence-thumb-image"
/>
<span v-if="isDefaultScreenshot(shot.url)" class="default-badge">默认占位图</span>
<span class="category-tag">{{ shot.label }}</span>
@@ -12,6 +12,7 @@ import {
ZoomIn,
ZoomOut,
} from '@element-plus/icons-vue'
import AuthImage from '@/shared/components/business/AuthImage.vue'
export interface PreviewScreenshotItem {
url: string
@@ -25,12 +26,10 @@ const props = withDefaults(
images: PreviewScreenshotItem[]
initialIndex?: number
isPeekMode?: boolean
previewUrls?: Record<string, string>
}>(),
{
initialIndex: 0,
isPeekMode: false,
previewUrls: () => ({}),
}
)
@@ -68,11 +67,6 @@ const currentItem = computed<PreviewScreenshotItem | null>(() => {
return props.images[currentIndex.value] || props.images[0] || null
})
const currentDisplayUrl = computed(() => {
if (!currentItem.value) return ''
return props.previewUrls[currentItem.value.url] || currentItem.value.url
})
const imageTransformStyle = computed(() => ({
transform: `scale(${zoomScale.value}) rotate(${rotationDeg.value}deg)`,
transition: 'transform 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
@@ -272,12 +266,13 @@ onUnmounted(() => {
<!-- Image Stage -->
<div class="image-stage" @click.self="handleClose">
<img
:src="currentDisplayUrl"
<AuthImage
:source="currentItem.url"
:alt="currentItem.label"
:style="imageTransformStyle"
class="preview-image"
draggable="false"
variant="medium"
:image-style="imageTransformStyle"
image-class="preview-image"
loading="eager"
/>
</div>
@@ -26,9 +26,10 @@ import {
WarningFilled,
} from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
import { fetchAdminFileBlob } from '@/shared/api/files'
import AuthImage from '@/shared/components/business/AuthImage.vue'
import { adminPath } from '@/shared/utils/adminPath'
import { centToYuan, formatCent, formatMoneyWithSymbol } from '@/shared/utils/money'
import {
@@ -54,8 +55,6 @@ import {
getFaceOwnerText,
getListingConsumablePrice,
getListingResources,
getScreenshotMediumURL,
getScreenshotThumbURL,
getOnlineTimeText,
getResourceQuantity,
getSkinNames,
@@ -103,13 +102,6 @@ interface ChecklistItem {
const _defaultScreenshotURL = '/api/listings/default-upload-screenshot?v=webp1'
function onThumbError(e: Event) {
const target = e.target as HTMLImageElement
if (target && target.src !== _defaultScreenshotURL) {
target.src = _defaultScreenshotURL
}
}
const sortOptions = [
{ label: '最新提交 (默认)', value: 'default' },
{ label: '风险优先 (封禁/默认图)', value: 'risk' },
@@ -145,7 +137,6 @@ const filters = reactive({
risk: 'all',
sortBy: 'default',
})
const previewURLs = reactive<Record<string, string>>({})
const lastRefreshedAt = ref<string>('')
const shortcutsDialogVisible = ref(false)
@@ -249,8 +240,6 @@ watch(
async listing => {
if (!listing) return
selectedID.value = listing.id
await nextTick()
prepareScreenshotPreviews(listing)
},
{ immediate: true }
)
@@ -455,7 +444,6 @@ async function onPriceAdjustSave(payload: {
function openEvidence(row: Listing) {
evidenceListing.value = row
evidenceDialogVisible.value = true
prepareScreenshotPreviews(row)
}
function money(value: number) {
@@ -780,12 +768,6 @@ function extractObjectKey(url: string) {
}
}
function prepareScreenshotPreviews(row: Listing) {
for (const url of row.screenshot_urls || []) {
previewURLs[url] = isDefaultScreenshot(url) ? url : getScreenshotMediumURL(url)
}
}
function getListingScreenshots(item: Listing | null): ReviewScreenshotItem[] {
if (!item) return []
const groups = item.asset_summary?.screenshot_groups
@@ -935,7 +917,6 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
evidenceListing.value.screenshot_urls = nextUrls
}
prepareScreenshotPreviews(targetListing)
editorVisible.value = false
editingScreenshot.value = null
}
@@ -1103,12 +1084,10 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
<div class="queue-main-row">
<div class="queue-thumb">
<img
:src="getScreenshotThumbURL(item.screenshot_urls?.[0]) || _defaultScreenshotURL"
<AuthImage
:source="item.screenshot_urls?.[0] || _defaultScreenshotURL"
alt="缩略图"
loading="lazy"
decoding="async"
@error="onThumbError"
variant="thumb"
/>
<span v-if="hasDefaultScreenshot(item)" class="thumb-warning-badge">默认图</span>
</div>
@@ -1591,11 +1570,12 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
@click="handleCardClick(selectedReviewScreenshots, index)"
>
<div class="image-wrapper">
<img
:src="getScreenshotThumbURL(shot.url)"
<AuthImage
:source="shot.url"
:alt="shot.label"
loading="lazy"
decoding="async"
variant="thumb"
image-class="screenshot-image"
fallback-class="screenshot-image"
/>
<span v-if="isDefaultScreenshot(shot.url)" class="default-badge">
<el-icon><Warning /></el-icon> 默认占位图
@@ -1702,7 +1682,6 @@ async function handleScreenshotSaved(payload: { oldUrl: string; newUrl: string }
v-model:is-peek-mode="isPeekMode"
:images="previewScreenshots"
:initial-index="previewInitialIndex"
:preview-urls="previewURLs"
@edit="handlePreviewEdit"
@open-raw="openRawScreenshot"
/>