check the file type and reject non-JSON file

This commit is contained in:
CodeMaker-Zhao 2023-01-02 08:43:47 +08:00
parent aaf606ba06
commit 9b70222ff9

View File

@ -54,7 +54,11 @@ export const ImportModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
e.preventDefault();
if (e.type === 'drop' && e.dataTransfer.files.length) {
setJsonFile(e.dataTransfer.files[0])
if (e.dataTransfer.files[0].type === 'application/json') {
setJsonFile(e.dataTransfer.files[0])
} else {
toast.error('Please upload JSON file!')
}
}
}