mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 22:44:28 +00:00
refactor(webui): modularize file viewer components into registry-driven architecture
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import { FileTypeDefinition } from './types'
|
||||
import { videoTypeDefinition } from './video'
|
||||
import { imageTypeDefinition } from './image'
|
||||
import { defaultTypeDefinition } from './default'
|
||||
|
||||
const registry: FileTypeDefinition[] = [videoTypeDefinition, imageTypeDefinition]
|
||||
|
||||
export function getViewerForFile(file: AssetInfo | null | undefined): FileTypeDefinition {
|
||||
if (!file) return defaultTypeDefinition
|
||||
const match = registry.find((viewer) => viewer.match(file))
|
||||
return match || defaultTypeDefinition
|
||||
}
|
||||
|
||||
export function getAllViewers(): FileTypeDefinition[] {
|
||||
return registry
|
||||
}
|
||||
Reference in New Issue
Block a user