文件格式检查
This commit is contained in:
parent
1a7e373aa1
commit
7694e79809
|
@ -119,6 +119,13 @@ export function UploadMusic(options) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
const files = Array.from(event.dataTransfer.files)
|
const files = Array.from(event.dataTransfer.files)
|
||||||
|
// 检查必须是音乐文件, 移除其它文件
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
if (!files[i].type.startsWith('audio/')) {
|
||||||
|
files.splice(i, 1)
|
||||||
|
i--
|
||||||
|
}
|
||||||
|
}
|
||||||
if (files.length === 0) return console.log('没有文件')
|
if (files.length === 0) return console.log('没有文件')
|
||||||
console.log('files', files)
|
console.log('files', files)
|
||||||
options.onchange(files)
|
options.onchange(files)
|
||||||
|
|
Loading…
Reference in New Issue