chore: update frontend configuration
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import { getFileIcon } from './fileIcons'
|
||||
|
||||
export const getPreviewType = (document) => {
|
||||
if (!document) return null
|
||||
if (!document) { return null }
|
||||
const mime = (document.mimeType || '').toLowerCase()
|
||||
const path = document.path || ''
|
||||
|
||||
const check = (prefix) => mime.startsWith(prefix) || path.startsWith(`data:${prefix}`)
|
||||
const check = prefix => mime.startsWith(prefix) || path.startsWith(`data:${prefix}`)
|
||||
|
||||
if (check('image/')) return 'image'
|
||||
if (mime === 'application/pdf' || path.startsWith('data:application/pdf')) return 'pdf'
|
||||
if (check('audio/')) return 'audio'
|
||||
if (check('video/')) return 'video'
|
||||
if (check('text/') || mime.includes('json') || mime.includes('xml') || path.startsWith('data:application/json')) return 'text'
|
||||
if (check('image/')) { return 'image' }
|
||||
if (mime === 'application/pdf' || path.startsWith('data:application/pdf')) { return 'pdf' }
|
||||
if (check('audio/')) { return 'audio' }
|
||||
if (check('video/')) { return 'video' }
|
||||
if (check('text/') || mime.includes('json') || mime.includes('xml') || path.startsWith('data:application/json')) { return 'text' }
|
||||
return null
|
||||
}
|
||||
|
||||
export const canPreviewDocument = (document = {}) => !!getPreviewType(document)
|
||||
|
||||
export const describeDocument = (document) => {
|
||||
if (!document) return ''
|
||||
if (!document) { return '' }
|
||||
const name = document.filename || document.name || ''
|
||||
const icon = getFileIcon({ name, mime: document.mimeType })
|
||||
return icon.label
|
||||
|
||||
Reference in New Issue
Block a user