feat: add charx import

This commit is contained in:
kwaroran
2024-06-03 16:59:44 +09:00
parent 8dff1a6cde
commit ad7ce3f0d1
3 changed files with 118 additions and 7 deletions

View File

@@ -125,12 +125,15 @@ export function selectFileByDom(allowedExtensions:string[], multiple:'multiple'|
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.multiple = multiple === 'multiple';
if(!(get(DataBase).allowAllExtentionFiles || checkIsIos())){
const acceptAll = (get(DataBase).allowAllExtentionFiles || checkIsIos() || allowedExtensions[0] === '*')
if(!acceptAll){
if (allowedExtensions && allowedExtensions.length) {
fileInput.accept = allowedExtensions.map(ext => `.${ext}`).join(',');
}
}
else{
fileInput.accept = '*'
}
fileInput.addEventListener('change', (event) => {
@@ -139,10 +142,10 @@ export function selectFileByDom(allowedExtensions:string[], multiple:'multiple'|
return;
}
const files = Array.from(fileInput.files).filter(file => {
const files = acceptAll ? Array.from(fileInput.files) :(Array.from(fileInput.files).filter(file => {
const fileExtension = file.name.split('.').pop().toLowerCase();
return !allowedExtensions || allowedExtensions.includes(fileExtension);
});
}))
fileInput.remove()
resolve(files);