前端: 添加文件格式校验,拒收非ncm/kgm/kgma/vpr格式文件

This commit is contained in:
ypshidifu
2026-09-17 20:50:47 +08:00
parent 2d48f178d4
commit f3ae835304
+7
View File
@@ -109,6 +109,8 @@
let files = [];
const SUPPORTED_EXTENSIONS = ['.ncm', '.kgm', '.kgma', '.vpr'];
// 点击上传区域选择文件
dropZone.addEventListener('click', () => fileInput.click());
@@ -139,6 +141,11 @@
function handleFiles(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;
files.push(f);
}