Add type for download format and noImplicitReturns rule
This commit is contained in:
parent
d2e81a6e77
commit
065e11ff2b
@ -12,7 +12,7 @@ export async function fetch(url: string, password: string = "") {
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
const data = await res.json();
|
const data = (await res.json()) as Resource;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
data.url = `/share${url}`;
|
data.url = `/share${url}`;
|
||||||
|
|
||||||
@ -33,12 +33,11 @@ export async function fetch(url: string, password: string = "") {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this redundant code?
|
|
||||||
export function download(
|
export function download(
|
||||||
format: any,
|
format: DownloadFormat,
|
||||||
hash: string,
|
hash: string,
|
||||||
token: string,
|
token: string,
|
||||||
...files: any
|
...files: string[]
|
||||||
) {
|
) {
|
||||||
let url = `${baseURL}/api/public/dl/${hash}`;
|
let url = `${baseURL}/api/public/dl/${hash}`;
|
||||||
|
|
||||||
|
|||||||
10
frontend/src/types/file.d.ts
vendored
10
frontend/src/types/file.d.ts
vendored
@ -34,3 +34,13 @@ type ResourceType =
|
|||||||
| "text"
|
| "text"
|
||||||
| "blob"
|
| "blob"
|
||||||
| "textImmutable";
|
| "textImmutable";
|
||||||
|
|
||||||
|
type DownloadFormat =
|
||||||
|
| "zip"
|
||||||
|
| "tar"
|
||||||
|
| "targz"
|
||||||
|
| "tarbz2"
|
||||||
|
| "tarxz"
|
||||||
|
| "tarlz4"
|
||||||
|
| "tarsz"
|
||||||
|
| null;
|
||||||
|
|||||||
@ -203,8 +203,8 @@ const error = ref<StatusError | null>(null);
|
|||||||
const showLimit = ref<number>(100);
|
const showLimit = ref<number>(100);
|
||||||
const password = ref<string>("");
|
const password = ref<string>("");
|
||||||
const attemptedPasswordLogin = ref<boolean>(false);
|
const attemptedPasswordLogin = ref<boolean>(false);
|
||||||
const hash = ref<any>(null);
|
const hash = ref<string>("");
|
||||||
const token = ref<any>(null);
|
const token = ref<string>("");
|
||||||
const clip = ref<any>(null);
|
const clip = ref<any>(null);
|
||||||
|
|
||||||
const $showSuccess = inject<IToastSuccess>("$showError")!;
|
const $showSuccess = inject<IToastSuccess>("$showError")!;
|
||||||
@ -308,18 +308,21 @@ const isSingleFile = () =>
|
|||||||
!req.value?.items[fileStore.selected[0]].isDir;
|
!req.value?.items[fileStore.selected[0]].isDir;
|
||||||
|
|
||||||
const download = () => {
|
const download = () => {
|
||||||
|
if (!req.value) return false;
|
||||||
|
|
||||||
if (isSingleFile()) {
|
if (isSingleFile()) {
|
||||||
api.download(
|
api.download(
|
||||||
null,
|
null,
|
||||||
hash.value,
|
hash.value,
|
||||||
token.value,
|
token.value,
|
||||||
req.value?.items[fileStore.selected[0]].path
|
req.value.items[fileStore.selected[0]].path
|
||||||
);
|
);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutStore.showHover({
|
layoutStore.showHover({
|
||||||
prompt: "download",
|
prompt: "download",
|
||||||
confirm: (format: any) => {
|
confirm: (format: DownloadFormat) => {
|
||||||
if (req.value === null) return false;
|
if (req.value === null) return false;
|
||||||
layoutStore.closeHovers();
|
layoutStore.closeHovers();
|
||||||
|
|
||||||
@ -330,8 +333,11 @@ const download = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api.download(format, hash.value, token.value, ...files);
|
api.download(format, hash.value, token.value, ...files);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const linkSelected = () => {
|
const linkSelected = () => {
|
||||||
|
|||||||
@ -329,6 +329,8 @@ const save = async () => {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
$showError(e);
|
$showError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
// Parse the user-friendly input (e.g., "20M" or "1T") to bytes
|
// Parse the user-friendly input (e.g., "20M" or "1T") to bytes
|
||||||
const parseBytes = (input: string) => {
|
const parseBytes = (input: string) => {
|
||||||
|
|||||||
@ -120,6 +120,7 @@ onMounted(() => {
|
|||||||
singleClick.value = authStore.user.singleClick;
|
singleClick.value = authStore.user.singleClick;
|
||||||
dateFormat.value = authStore.user.dateFormat;
|
dateFormat.value = authStore.user.dateFormat;
|
||||||
layoutStore.loading = false;
|
layoutStore.loading = false;
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatePassword = async (event: Event) => {
|
const updatePassword = async (event: Event) => {
|
||||||
|
|||||||
@ -154,6 +154,8 @@ const deleteUser = async (e: Event) => {
|
|||||||
$showError(err);
|
$showError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
const save = async (event: Event) => {
|
const save = async (event: Event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -183,5 +185,7 @@ const save = async (event: Event) => {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
$showError(e);
|
$showError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"moduleResolution": "Node10",
|
"moduleResolution": "Node10",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user