mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(transcode): add PDF proxy support for TXT and CSV files
This commit is contained in:
@@ -4,8 +4,10 @@ import { formatTime } from '../viewers/video/utils'
|
||||
|
||||
type FilePreviewItem = {
|
||||
type?: string | null
|
||||
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | null
|
||||
preview?: {
|
||||
mediaType?: string | null
|
||||
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | null
|
||||
spriteUrl?: string
|
||||
thumbnailUrl?: string
|
||||
originalWidth?: number
|
||||
@@ -21,9 +23,10 @@ interface FilePreviewProps {
|
||||
}
|
||||
|
||||
export const FilePreview = ({ item, showDuration = false }: FilePreviewProps) => {
|
||||
const isVideo = item.preview?.mediaType?.startsWith('video/')
|
||||
const isAudio = item.preview?.mediaType?.startsWith('audio/')
|
||||
const isPdf = item.preview?.mediaType === 'application/pdf'
|
||||
const proxyType = item.preview?.proxyType || item.proxyType
|
||||
const isVideo = proxyType === 'video'
|
||||
const isAudio = proxyType === 'audio'
|
||||
const isPdf = proxyType === 'pdf'
|
||||
const hasDuration = isVideo || isAudio
|
||||
const duration = item.preview?.duration
|
||||
const pageCount = item.preview?.pageCount
|
||||
|
||||
@@ -5,7 +5,7 @@ import { CompareImagePane } from './compare-image-pane'
|
||||
export const imageTypeDefinition: FileTypeDefinition = {
|
||||
id: 'image',
|
||||
name: 'Image',
|
||||
match: (file) => !!file.mediaType?.startsWith('image/'),
|
||||
match: (file) => file.proxyType === 'image',
|
||||
viewer: ImageViewer,
|
||||
comparePane: CompareImagePane,
|
||||
commentsConfig: {
|
||||
|
||||
@@ -4,7 +4,7 @@ import PdfViewer from './pdf-viewer'
|
||||
export const pdfTypeDefinition: FileTypeDefinition = {
|
||||
id: 'pdf',
|
||||
name: 'PDF',
|
||||
match: (file) => file.mediaType === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf'),
|
||||
match: (file) => file.proxyType === 'pdf',
|
||||
viewer: PdfViewer,
|
||||
commentsConfig: {
|
||||
hasTimestamp: true,
|
||||
|
||||
@@ -132,7 +132,7 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
}
|
||||
}, [])
|
||||
|
||||
const fileUrl = file.media?.original?.downloadUrl
|
||||
const fileUrl = file.media?.pdfTranscode?.url || file.media?.original?.downloadUrl
|
||||
|
||||
// Load PDF Document
|
||||
useEffect(() => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { CompareVideoPane } from './compare-video-pane'
|
||||
export const videoTypeDefinition: FileTypeDefinition = {
|
||||
id: 'video',
|
||||
name: 'Video',
|
||||
match: (file) => !!file.mediaType?.startsWith('video/') || !!file.mediaType?.startsWith('audio/'),
|
||||
match: (file) => file.proxyType === 'video' || file.proxyType === 'audio',
|
||||
viewer: VideoViewer,
|
||||
comparePane: CompareVideoPane,
|
||||
commentsConfig: {
|
||||
|
||||
Reference in New Issue
Block a user