fix(front): update FileUpload component to allow all file types and improve type checking for accepted file formats

This commit is contained in:
keven1024
2025-04-20 21:13:32 +08:00
parent d48cf960f8
commit a45eed2fbb

View File

@@ -6,7 +6,7 @@ const props = defineProps<{
accept?: string[]
}>()
const accept = computed(() => (props?.accept || ['image/*', 'video/*'])?.join(','))
const accept = computed(() => (props?.accept || ['*'])?.join(','))
const emit = defineEmits<{
(e: 'onChange', file: File): void
@@ -24,6 +24,9 @@ const { isOverDropZone } = useDropZone(dropZoneRef, {
for (const acceptType of accept.value.split(',')) {
if (acceptType?.endsWith('*')) {
const [acceptTypePrefix,] = acceptType?.split('/')
if (!acceptTypePrefix) {
return true
}
if (type?.startsWith(acceptTypePrefix)) {
return true
}