From 5e92660d1cdc8e38c511ebc992263828029b41fc Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 19 Jun 2026 13:25:00 +0800 Subject: [PATCH] fix(webui): render sprite image scrubber for video upload notifications --- .../core/src/notification/notification.ts | 14 ++++++++++++++ packages/dtos/src/notification.ts | 3 +++ .../webui/components/notification-card.tsx | 19 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/core/src/notification/notification.ts b/packages/core/src/notification/notification.ts index f2be2293..aae90dac 100644 --- a/packages/core/src/notification/notification.ts +++ b/packages/core/src/notification/notification.ts @@ -371,6 +371,9 @@ export class NotificationService { if (n.asset) { const a = n.asset let previewUrl = '' + let thumbnailUrl = '' + let originalWidth = 0 + let originalHeight = 0 const media = a.media as PrismaJson.MediaInfo | null @@ -379,8 +382,16 @@ export class NotificationService { try { if (media.sprite) { previewUrl = await s3Service.presign(bucket, media.sprite.key, 'GET') + if (media.thumbnail) { + thumbnailUrl = await s3Service.presign(bucket, media.thumbnail.key || '', 'GET') + } + if (media.metadata) { + originalWidth = media.metadata.originalWidth + originalHeight = media.metadata.originalHeight + } } else if (media.thumbnail) { previewUrl = await s3Service.presign(bucket, media.thumbnail.key || '', 'GET') + thumbnailUrl = previewUrl } } catch (e) { console.error('Failed to generate presigned url for notification asset preview:', e) @@ -392,6 +403,9 @@ export class NotificationService { name: a.name, mediaType: a.mediaType || undefined, preview: previewUrl || undefined, + thumbnailUrl: thumbnailUrl || undefined, + originalWidth: originalWidth || undefined, + originalHeight: originalHeight || undefined, } } diff --git a/packages/dtos/src/notification.ts b/packages/dtos/src/notification.ts index 34d32276..024c6646 100644 --- a/packages/dtos/src/notification.ts +++ b/packages/dtos/src/notification.ts @@ -21,6 +21,9 @@ export const assetPreviewSchema = z.object({ mediaType: z.string().optional(), name: z.string().optional(), preview: z.string().optional(), + thumbnailUrl: z.string().optional(), + originalWidth: z.number().optional(), + originalHeight: z.number().optional(), }) export type AssetPreview = z.infer diff --git a/packages/webui/components/notification-card.tsx b/packages/webui/components/notification-card.tsx index 019a41ac..27b70350 100644 --- a/packages/webui/components/notification-card.tsx +++ b/packages/webui/components/notification-card.tsx @@ -1,6 +1,7 @@ import type { NotificationInfo } from '@shumai/dtos' import { formatTimeAgo } from '@/ui/lib/time' import { cn } from '@/ui/lib/utils' +import { SpriteScrubber } from './sprite-scrubber' interface NotificationCardProps { notification: NotificationInfo @@ -76,6 +77,13 @@ export const NotificationCard = ({ notification }: NotificationCardProps) => { } })() + const isVideoWithSprite = + asset?.mediaType?.startsWith('video/') && + asset.preview && + asset.thumbnailUrl && + asset.originalWidth && + asset.originalHeight + const hasPreview = asset?.preview && (asset.mediaType?.startsWith('image') || asset.mediaType?.startsWith('video')) @@ -98,7 +106,16 @@ export const NotificationCard = ({ notification }: NotificationCardProps) => { {hasPreview && (
- {asset!.name} + {isVideoWithSprite ? ( + + ) : ( + {asset!.name} + )}
)}