Browse Source

fix(gui-v2): use mime types

pull/3428/head
Wing-Kam Wong 2 years ago
parent
commit
62d7d8e317
  1. 16
      packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue

16
packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue

@ -20,13 +20,18 @@ type QuickImportTypes = 'excel' | 'json' | 'csv'
const allowedQuickImportTypes = [
// Excel
'.xls, .xlsx, .xlsm, .ods, .ots',
'application/vnd.ms-excel', // .xls
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx
'application/vnd.ms-excel.sheet.macroenabled.12', // .xlsm
'application/vnd.oasis.opendocument.spreadsheet', // .ods
'application/vnd.oasis.opendocument.spreadsheet-template', // .ots
// CSV
'.csv',
'text/csv',
// JSON
'.json',
'application/json',
'text/json',
]
watch(files, (nextFiles) => nextFiles && onFileSelect(nextFiles), { flush: 'post' })
@ -52,10 +57,11 @@ function onDrop(droppedFiles: File[] | null) {
let fileType: QuickImportTypes | null = null
const isValid = allowedQuickImportTypes.some((type) => {
const isAllowed = droppedFiles[0].type.replace('/', '.').endsWith(type)
const isAllowed = droppedFiles[0].type === type
if (isAllowed) {
fileType = type.replace('.', '') as QuickImportTypes
const ext = droppedFiles[0].name.split('.').pop()
fileType = (ext === 'csv' || ext === 'json') ? ext : 'excel' as QuickImportTypes
}
return isAllowed

Loading…
Cancel
Save