前端: 添加文件格式校验,拒收非ncm/kgm/kgma/vpr格式文件
This commit is contained in:
@@ -109,6 +109,8 @@
|
|||||||
|
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
|
const SUPPORTED_EXTENSIONS = ['.ncm', '.kgm', '.kgma', '.vpr'];
|
||||||
|
|
||||||
// 点击上传区域选择文件
|
// 点击上传区域选择文件
|
||||||
dropZone.addEventListener('click', () => fileInput.click());
|
dropZone.addEventListener('click', () => fileInput.click());
|
||||||
|
|
||||||
@@ -139,6 +141,11 @@
|
|||||||
|
|
||||||
function handleFiles(fileListObj) {
|
function handleFiles(fileListObj) {
|
||||||
for (const f of fileListObj) {
|
for (const f of fileListObj) {
|
||||||
|
const ext = f.name.slice(f.name.lastIndexOf('.')).toLowerCase();
|
||||||
|
if (!SUPPORTED_EXTENSIONS.includes(ext)) {
|
||||||
|
alert('不支持的文件格式: ' + f.name + '\\n仅支持: .ncm / .kgm / .kgma / .vpr');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (files.some(existing => existing.name === f.name)) continue;
|
if (files.some(existing => existing.name === f.name)) continue;
|
||||||
files.push(f);
|
files.push(f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user