chore: add prettier frontent linter

This commit is contained in:
Oleg Lobanov
2021-03-21 12:51:58 +01:00
parent a721dc1f31
commit c44b37c50c
73 changed files with 18898 additions and 4499 deletions

View File

@@ -1,124 +1,127 @@
import store from '@/store'
import url from '@/utils/url'
import store from "@/store";
import url from "@/utils/url";
export function checkConflict(files, items) {
if (typeof items === 'undefined' || items === null) {
items = []
if (typeof items === "undefined" || items === null) {
items = [];
}
let folder_upload = files[0].fullPath !== undefined
let folder_upload = files[0].fullPath !== undefined;
let conflict = false
let conflict = false;
for (let i = 0; i < files.length; i++) {
let file = files[i]
let name = file.name
let file = files[i];
let name = file.name;
if (folder_upload) {
let dirs = file.fullPath.split("/")
let dirs = file.fullPath.split("/");
if (dirs.length > 1) {
name = dirs[0]
name = dirs[0];
}
}
let res = items.findIndex(function hasConflict(element) {
return (element.name === this)
}, name)
return element.name === this;
}, name);
if (res >= 0) {
conflict = true
break
conflict = true;
break;
}
}
return conflict
return conflict;
}
export function scanFiles(dt) {
return new Promise((resolve) => {
let reading = 0
const contents = []
let reading = 0;
const contents = [];
if (dt.items !== undefined) {
for (let item of dt.items) {
if (item.kind === "file" && typeof item.webkitGetAsEntry === "function") {
const entry = item.webkitGetAsEntry()
readEntry(entry)
if (
item.kind === "file" &&
typeof item.webkitGetAsEntry === "function"
) {
const entry = item.webkitGetAsEntry();
readEntry(entry);
}
}
} else {
resolve(dt.files)
resolve(dt.files);
}
function readEntry(entry, directory = "") {
if (entry.isFile) {
reading++
entry.file(file => {
reading--
reading++;
entry.file((file) => {
reading--;
file.fullPath = `${directory}${file.name}`
contents.push(file)
file.fullPath = `${directory}${file.name}`;
contents.push(file);
if (reading === 0) {
resolve(contents)
resolve(contents);
}
})
});
} else if (entry.isDirectory) {
const dir = {
isDir: true,
size: 0,
fullPath: `${directory}${entry.name}`
}
fullPath: `${directory}${entry.name}`,
};
contents.push(dir)
contents.push(dir);
readReaderContent(entry.createReader(), `${directory}${entry.name}`)
readReaderContent(entry.createReader(), `${directory}${entry.name}`);
}
}
function readReaderContent(reader, directory) {
reading++
reading++;
reader.readEntries(function (entries) {
reading--
reading--;
if (entries.length > 0) {
for (const entry of entries) {
readEntry(entry, `${directory}/`)
readEntry(entry, `${directory}/`);
}
readReaderContent(reader, `${directory}/`)
readReaderContent(reader, `${directory}/`);
}
if (reading === 0) {
resolve(contents)
resolve(contents);
}
})
});
}
})
});
}
export function handleFiles(files, base, overwrite = false) {
for (let i = 0; i < files.length; i++) {
let id = store.state.upload.id
let path = base
let file = files[i]
let id = store.state.upload.id;
let path = base;
let file = files[i];
if (file.fullPath !== undefined) {
path += url.encodePath(file.fullPath)
path += url.encodePath(file.fullPath);
} else {
path += url.encodeRFC5987ValueChars(file.name)
path += url.encodeRFC5987ValueChars(file.name);
}
if (file.isDir) {
path += '/'
path += "/";
}
const item = {
id,
path,
file,
overwrite
}
overwrite,
};
store.dispatch('upload/upload', item);
store.dispatch("upload/upload", item);
}
}
}