Fixed some type & eslint errors
This commit is contained in:
parent
01b1373130
commit
06fe5429ab
@ -3,7 +3,7 @@ import { baseURL } from "@/utils/constants";
|
|||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { upload as postTus, useTus } from "./tus";
|
import { upload as postTus, useTus } from "./tus";
|
||||||
|
|
||||||
export async function fetch(url: apiUrl) {
|
export async function fetch(url: ApiUrl) {
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
|
|
||||||
const res = await fetchURL(`/api/resources${url}`, {});
|
const res = await fetchURL(`/api/resources${url}`, {});
|
||||||
@ -29,11 +29,10 @@ export async function fetch(url: apiUrl) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resourceAction(url: apiUrl, method: apiMethod, content?: any) {
|
async function resourceAction(url: ApiUrl, method: ApiMethod, content?: any) {
|
||||||
debugger;
|
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
|
|
||||||
const opts: apiOpts = {
|
const opts: ApiOpts = {
|
||||||
method,
|
method,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,11 +45,11 @@ async function resourceAction(url: apiUrl, method: apiMethod, content?: any) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove(url: apiUrl) {
|
export async function remove(url: ApiUrl) {
|
||||||
return resourceAction(url, "DELETE");
|
return resourceAction(url, "DELETE");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function put(url: apiUrl, content = "") {
|
export async function put(url: ApiUrl, content = "") {
|
||||||
return resourceAction(url, "PUT", content);
|
return resourceAction(url, "PUT", content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +83,10 @@ export function download(format: any, ...files: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function post(
|
export async function post(
|
||||||
url: apiUrl,
|
url: ApiUrl,
|
||||||
content: apiContent = "",
|
content: ApiContent = "",
|
||||||
overwrite = false,
|
overwrite = false,
|
||||||
onupload: Function = () => {}
|
onupload: any = () => {}
|
||||||
) {
|
) {
|
||||||
// Use the pre-existing API if:
|
// Use the pre-existing API if:
|
||||||
const useResourcesApi =
|
const useResourcesApi =
|
||||||
@ -104,8 +103,8 @@ export async function post(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function postResources(
|
async function postResources(
|
||||||
url: apiUrl,
|
url: ApiUrl,
|
||||||
content: apiContent = "",
|
content: ApiContent = "",
|
||||||
overwrite = false,
|
overwrite = false,
|
||||||
onupload: any
|
onupload: any
|
||||||
) {
|
) {
|
||||||
@ -152,7 +151,7 @@ async function postResources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moveCopy(
|
function moveCopy(
|
||||||
items: item[],
|
items: any[],
|
||||||
copy = false,
|
copy = false,
|
||||||
overwrite = false,
|
overwrite = false,
|
||||||
rename = false
|
rename = false
|
||||||
@ -171,20 +170,20 @@ function moveCopy(
|
|||||||
return Promise.all(promises);
|
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);
|
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);
|
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");
|
const data = await resourceAction(`${url}?checksum=${algo}`, "GET");
|
||||||
return (await data.json()).checksums[algo];
|
return (await data.json()).checksums[algo];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDownloadURL(file: file, inline: any) {
|
export function getDownloadURL(file: IFile, inline: any) {
|
||||||
const params = {
|
const params = {
|
||||||
...(inline && { inline: "true" }),
|
...(inline && { inline: "true" }),
|
||||||
};
|
};
|
||||||
@ -192,7 +191,7 @@ export function getDownloadURL(file: file, inline: any) {
|
|||||||
return createURL("api/raw" + file.path, params);
|
return createURL("api/raw" + file.path, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPreviewURL(file: file, size: string) {
|
export function getPreviewURL(file: IFile, size: string) {
|
||||||
const params = {
|
const params = {
|
||||||
inline: "true",
|
inline: "true",
|
||||||
key: Date.parse(file.modified),
|
key: Date.parse(file.modified),
|
||||||
@ -201,7 +200,7 @@ export function getPreviewURL(file: file, size: string) {
|
|||||||
return createURL("api/preview/" + size + file.path, params);
|
return createURL("api/preview/" + size + file.path, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSubtitlesURL(file: file) {
|
export function getSubtitlesURL(file: IFile) {
|
||||||
const params = {
|
const params = {
|
||||||
inline: "true",
|
inline: "true",
|
||||||
};
|
};
|
||||||
@ -214,7 +213,7 @@ export function getSubtitlesURL(file: file) {
|
|||||||
return subtitles;
|
return subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function usage(url: apiUrl) {
|
export async function usage(url: ApiUrl) {
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
|
|
||||||
const res = await fetchURL(`/api/usage${url}`, {});
|
const res = await fetchURL(`/api/usage${url}`, {});
|
||||||
|
|||||||
@ -9,9 +9,9 @@ const RETRY_MAX_DELAY = 20000;
|
|||||||
|
|
||||||
export async function upload(
|
export async function upload(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
content: apiContent = "",
|
content: ApiContent = "",
|
||||||
overwrite = false,
|
overwrite = false,
|
||||||
onupload: Function
|
onupload: any
|
||||||
) {
|
) {
|
||||||
if (!tusSettings) {
|
if (!tusSettings) {
|
||||||
// Shouldn't happen as we check for tus support before calling this function
|
// 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;
|
return retryDelays;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useTus(content: apiContent) {
|
export async function useTus(content: ApiContent) {
|
||||||
return isTusSupported() && content instanceof Blob;
|
return isTusSupported() && content instanceof Blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
defineAsyncComponent,
|
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
onMounted,
|
onMounted,
|
||||||
onUnmounted,
|
onUnmounted,
|
||||||
@ -42,14 +41,13 @@ import HeaderBar from "@/components/header/HeaderBar.vue";
|
|||||||
import Breadcrumbs from "@/components/Breadcrumbs.vue";
|
import Breadcrumbs from "@/components/Breadcrumbs.vue";
|
||||||
import Errors from "@/views/Errors.vue";
|
import Errors from "@/views/Errors.vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
const fileStore = useFileStore();
|
const fileStore = useFileStore();
|
||||||
const uploadStore = useUploadStore();
|
const uploadStore = useUploadStore();
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const { t } = useI18n({});
|
const { t } = useI18n({});
|
||||||
|
|
||||||
@ -57,9 +55,7 @@ const clean = (path: string) => {
|
|||||||
return path.endsWith("/") ? path.slice(0, -1) : path;
|
return path.endsWith("/") ? path.slice(0, -1) : path;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Editor = defineAsyncComponent(() => import("@/views/files/Editor.vue"));
|
|
||||||
const error = ref<any | null>(null);
|
const error = ref<any | null>(null);
|
||||||
const width = computed(() => window.innerWidth);
|
|
||||||
|
|
||||||
const currentView = computed(() => {
|
const currentView = computed(() => {
|
||||||
if (fileStore.req?.type == undefined) {
|
if (fileStore.req?.type == undefined) {
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { mapActions, mapState, mapWritableState } from "pinia";
|
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
import { useFileStore } from "@/stores/file";
|
import { useFileStore } from "@/stores/file";
|
||||||
@ -27,7 +26,7 @@ import Prompts from "@/components/prompts/Prompts.vue";
|
|||||||
import Shell from "@/components/Shell.vue";
|
import Shell from "@/components/Shell.vue";
|
||||||
import UploadFiles from "@/components/prompts/UploadFiles.vue";
|
import UploadFiles from "@/components/prompts/UploadFiles.vue";
|
||||||
import { enableExec } from "@/utils/constants";
|
import { enableExec } from "@/utils/constants";
|
||||||
import { computed, watch } from "vue";
|
import { watch } from "vue";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
@ -35,7 +34,7 @@ const authStore = useAuthStore();
|
|||||||
const fileStore = useFileStore();
|
const fileStore = useFileStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
watch(route, (newval, oldval) => {
|
watch(route, () => {
|
||||||
fileStore.selected = [];
|
fileStore.selected = [];
|
||||||
fileStore.multiple = false;
|
fileStore.multiple = false;
|
||||||
if (layoutStore.show !== "success") {
|
if (layoutStore.show !== "success") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user