Skip to content

Commit 4213f11

Browse files
committed
feat(admin): show preview and capture images in enrichment detail
1 parent 4774fae commit 4213f11

2 files changed

Lines changed: 40 additions & 37 deletions

File tree

apps/admin/src/views/enrichment/components/cache/cache-detail-panel.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ export const CacheDetailPanel = defineComponent({
148148
.filter(Boolean)
149149
.join(' · ')
150150
const captureMeta = row.capture
151-
const normalizedCapture = row.normalized.captureImage
152151

153152
return (
154153
<div class="flex h-full flex-col">
@@ -229,21 +228,6 @@ export const CacheDetailPanel = defineComponent({
229228
</div>
230229
{captureMeta ? (
231230
<div class="space-y-2">
232-
{normalizedCapture?.url && (
233-
<a
234-
href={normalizedCapture.url}
235-
target="_blank"
236-
rel="noopener noreferrer"
237-
class="block max-w-md overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-800"
238-
>
239-
<img
240-
src={normalizedCapture.url}
241-
alt="screenshot"
242-
class="w-full object-cover"
243-
loading="lazy"
244-
/>
245-
</a>
246-
)}
247231
<div class="flex flex-wrap gap-x-4 gap-y-1 text-xs text-neutral-500 dark:text-neutral-400">
248232
<span>
249233
{captureMeta.width}×{captureMeta.height}

apps/admin/src/views/enrichment/components/cache/cache-normalized-section.tsx

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { defineComponent } from 'vue'
2-
import type { EnrichmentResult } from '~/models/enrichment'
2+
import type { EnrichmentImage, EnrichmentResult } from '~/models/enrichment'
33
import type { PropType } from 'vue'
44

5+
const IMAGE_FIELDS = [
6+
{ key: 'thumbnailImage', label: '封面图' },
7+
{ key: 'previewImage', label: 'OG 预览图' },
8+
{ key: 'captureImage', label: '截图' },
9+
] as const
10+
511
export const CacheNormalizedSection = defineComponent({
612
name: 'CacheNormalizedSection',
713
props: {
@@ -11,7 +17,6 @@ export const CacheNormalizedSection = defineComponent({
1117
setup(props) {
1218
return () => {
1319
const { result } = props
14-
const image = result.thumbnailImage
1520
const attributes = result.attributes ?? []
1621
const links = result.links ?? []
1722
return (
@@ -30,25 +35,15 @@ export const CacheNormalizedSection = defineComponent({
3035
{result.description || '—'}
3136
</span>
3237
</Field>
33-
<Field label="封面图">
34-
{image ? (
35-
<a
36-
href={image.url}
37-
target="_blank"
38-
rel="noopener noreferrer"
39-
class="block max-w-xs overflow-hidden rounded-md border border-neutral-200 dark:border-neutral-800"
40-
>
41-
<img
42-
src={image.url}
43-
alt={image.alt || ''}
44-
class="w-full object-cover"
45-
loading="lazy"
46-
/>
47-
</a>
48-
) : (
49-
<span class="text-xs text-neutral-400"></span>
50-
)}
51-
</Field>
38+
{IMAGE_FIELDS.map(({ key, label }) => {
39+
const img = result[key]
40+
if (!img?.url) return null
41+
return (
42+
<Field key={key} label={label}>
43+
<ImagePreview image={img} />
44+
</Field>
45+
)
46+
})}
5247
{attributes.length > 0 && (
5348
<Field label="属性">
5449
<div class="overflow-hidden rounded-md border border-neutral-200 dark:border-neutral-800">
@@ -113,3 +108,27 @@ const Field = defineComponent({
113108
)
114109
},
115110
})
111+
112+
const ImagePreview = defineComponent({
113+
name: 'ImagePreview',
114+
props: {
115+
image: { type: Object as PropType<EnrichmentImage>, required: true },
116+
},
117+
setup(props) {
118+
return () => (
119+
<a
120+
href={props.image.url}
121+
target="_blank"
122+
rel="noopener noreferrer"
123+
class="block max-w-xs overflow-hidden rounded-md border border-neutral-200 dark:border-neutral-800"
124+
>
125+
<img
126+
src={props.image.url}
127+
alt={props.image.alt || ''}
128+
class="w-full object-cover"
129+
loading="lazy"
130+
/>
131+
</a>
132+
)
133+
},
134+
})

0 commit comments

Comments
 (0)