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