Fixed some type & eslint errors

This commit is contained in:
Joep 2023-09-09 14:16:20 +02:00
parent 01b1373130
commit 06fe5429ab
4 changed files with 24 additions and 30 deletions

View File

@ -3,7 +3,7 @@ import { baseURL } from "@/utils/constants";
import { useAuthStore } from "@/stores/auth";
import { upload as postTus, useTus } from "./tus";
export async function fetch(url: apiUrl) {
export async function fetch(url: ApiUrl) {
url = removePrefix(url);
const res = await fetchURL(`/api/resources${url}`, {});
@ -29,11 +29,10 @@ export async function fetch(url: apiUrl) {
return data;
}
async function resourceAction(url: apiUrl, method: apiMethod, content?: any) {
debugger;
async function resourceAction(url: ApiUrl, method: ApiMethod, content?: any) {
url = removePrefix(url);
const opts: apiOpts = {
const opts: ApiOpts = {
method,
};
@ -46,11 +45,11 @@ async function resourceAction(url: apiUrl, method: apiMethod, content?: any) {
return res;
}
export async function remove(url: apiUrl) {
export async function remove(url: ApiUrl) {
return resourceAction(url, "DELETE");
}
export async function put(url: apiUrl, content = "") {
export async function put(url: ApiUrl, content = "") {
return resourceAction(url, "PUT", content);
}
@ -84,10 +83,10 @@ export function download(format: any, ...files: string[]) {
}
export async function post(
url: apiUrl,
content: apiContent = "",
url: ApiUrl,
content: ApiContent = "",
overwrite = false,
onupload: Function = () => {}
onupload: any = () => {}
) {
// Use the pre-existing API if:
const useResourcesApi =
@ -104,8 +103,8 @@ export async function post(
}
async function postResources(
url: apiUrl,
content: apiContent = "",
url: ApiUrl,
content: ApiContent = "",
overwrite = false,
onupload: any
) {
@ -152,7 +151,7 @@ async function postResources(
}
function moveCopy(
items: item[],
items: any[],
copy = false,
overwrite = false,
rename = false
@ -171,20 +170,20 @@ function moveCopy(
return Promise.all(promises);
}
export function move(items: item[], overwrite = false, rename = false) {
export function move(items: any[], overwrite = false, rename = false) {
return moveCopy(items, false, overwrite, rename);
}
export function copy(items: item[], overwrite = false, rename = false) {
export function copy(items: any[], overwrite = false, rename = false) {
return moveCopy(items, true, overwrite, rename);
}
export async function checksum(url: apiUrl, algo: algo) {
export async function checksum(url: ApiUrl, algo: algo) {
const data = await resourceAction(`${url}?checksum=${algo}`, "GET");
return (await data.json()).checksums[algo];
}
export function getDownloadURL(file: file, inline: any) {
export function getDownloadURL(file: IFile, inline: any) {
const params = {
...(inline && { inline: "true" }),
};
@ -192,7 +191,7 @@ export function getDownloadURL(file: file, inline: any) {
return createURL("api/raw" + file.path, params);
}
export function getPreviewURL(file: file, size: string) {
export function getPreviewURL(file: IFile, size: string) {
const params = {
inline: "true",
key: Date.parse(file.modified),
@ -201,7 +200,7 @@ export function getPreviewURL(file: file, size: string) {
return createURL("api/preview/" + size + file.path, params);
}
export function getSubtitlesURL(file: file) {
export function getSubtitlesURL(file: IFile) {
const params = {
inline: "true",
};
@ -214,7 +213,7 @@ export function getSubtitlesURL(file: file) {
return subtitles;
}
export async function usage(url: apiUrl) {
export async function usage(url: ApiUrl) {
url = removePrefix(url);
const res = await fetchURL(`/api/usage${url}`, {});

View File

@ -9,9 +9,9 @@ const RETRY_MAX_DELAY = 20000;
export async function upload(
filePath: string,
content: apiContent = "",
content: ApiContent = "",
overwrite = false,
onupload: Function
onupload: any
) {
if (!tusSettings) {
// Shouldn't happen as we check for tus support before calling this function
@ -87,7 +87,7 @@ function computeRetryDelays(tusSettings: tusSettings): number[] | undefined {
return retryDelays;
}
export async function useTus(content: apiContent) {
export async function useTus(content: ApiContent) {
return isTusSupported() && content instanceof Blob;
}

View File

@ -26,7 +26,6 @@
<script setup lang="ts">
import {
computed,
defineAsyncComponent,
onBeforeUnmount,
onMounted,
onUnmounted,
@ -42,14 +41,13 @@ import HeaderBar from "@/components/header/HeaderBar.vue";
import Breadcrumbs from "@/components/Breadcrumbs.vue";
import Errors from "@/views/Errors.vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { useRoute } from "vue-router";
const layoutStore = useLayoutStore();
const fileStore = useFileStore();
const uploadStore = useUploadStore();
const route = useRoute();
const router = useRouter();
const { t } = useI18n({});
@ -57,9 +55,7 @@ const clean = (path: string) => {
return path.endsWith("/") ? path.slice(0, -1) : path;
};
const Editor = defineAsyncComponent(() => import("@/views/files/Editor.vue"));
const error = ref<any | null>(null);
const width = computed(() => window.innerWidth);
const currentView = computed(() => {
if (fileStore.req?.type == undefined) {

View File

@ -18,7 +18,6 @@
</template>
<script setup lang="ts">
import { mapActions, mapState, mapWritableState } from "pinia";
import { useAuthStore } from "@/stores/auth";
import { useLayoutStore } from "@/stores/layout";
import { useFileStore } from "@/stores/file";
@ -27,7 +26,7 @@ import Prompts from "@/components/prompts/Prompts.vue";
import Shell from "@/components/Shell.vue";
import UploadFiles from "@/components/prompts/UploadFiles.vue";
import { enableExec } from "@/utils/constants";
import { computed, watch } from "vue";
import { watch } from "vue";
import { useRoute } from "vue-router";
const layoutStore = useLayoutStore();
@ -35,7 +34,7 @@ const authStore = useAuthStore();
const fileStore = useFileStore();
const route = useRoute();
watch(route, (newval, oldval) => {
watch(route, () => {
fileStore.selected = [];
fileStore.multiple = false;
if (layoutStore.show !== "success") {