mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
fix: filter empty URLs in image gallery to prevent browser reload
- Add validation to filter out empty and whitespace-only image URLs - Return null when no valid images exist - Prevents console errors and browser reload issues from empty img src 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -32,12 +32,15 @@ const ImageGallery: FC<Props> = ({
|
||||
}) => {
|
||||
const [imagePreviewUrl, setImagePreviewUrl] = useState('')
|
||||
|
||||
const imgNum = srcs.length
|
||||
const validSrcs = srcs.filter(src => src && src.trim() !== '')
|
||||
const imgNum = validSrcs.length
|
||||
const imgStyle = getWidthStyle(imgNum)
|
||||
|
||||
if (imgNum === 0) { return null }
|
||||
|
||||
return (
|
||||
<div className={cn(s[`img-${imgNum}`], 'flex flex-wrap')}>
|
||||
{/* TODO: support preview */}
|
||||
{srcs.map((src, index) => (
|
||||
{validSrcs.map((src, index) => (
|
||||
<img
|
||||
key={index}
|
||||
className={s.item}
|
||||
|
||||
Reference in New Issue
Block a user