Post list

This commit is contained in:
2025-01-04 13:27:33 +08:00
parent 8cbdc7c870
commit e123aabf0f
5 changed files with 143 additions and 7 deletions

View File

@@ -2,24 +2,25 @@ import { SnAttachment } from '@/services/attachment'
import { getAttachmentUrl } from '@/services/network'
import { QuestionMark } from '@mui/icons-material'
import { Link, Paper, Typography } from '@mui/material'
import { ComponentProps } from 'react'
export function AttachmentItem({ item }: { item: SnAttachment }) {
export function AttachmentItem({ item, ...rest }: { item: SnAttachment } & ComponentProps<'div'>) {
switch (item.mimetype.split('/')[0]) {
case 'image':
return (
<Paper>
<Paper {...rest}>
<img src={getAttachmentUrl(item.rid)} alt={item.alt} style={{ objectFit: 'cover', borderRadius: '8px' }} />
</Paper>
)
case 'video':
return (
<Paper>
<Paper {...rest}>
<video src={getAttachmentUrl(item.rid)} controls style={{ borderRadius: '8px' }} />
</Paper>
)
default:
return (
<Paper sx={{ width: '100%', height: '100%', p: 5, textAlign: 'center' }}>
<Paper sx={{ width: '100%', height: '100%', p: 5, textAlign: 'center' }} {...rest}>
<QuestionMark sx={{ mb: 2 }} />
<Typography>Unknown</Typography>
<Typography gutterBottom>{item.name}</Typography>