diff --git a/src/lib/api.ts b/src/lib/api.ts index bc5c2e6..476c1ad 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -8,7 +8,13 @@ export const client = ky.create({ export const api = { file: async (uid: string) => await client.get(uid), - list: async () => await client.get('list').json(), + list: async (page?: number, size?: number) => { + const searchParams = new URLSearchParams(); + if (page !== undefined) searchParams.append('page', String(page)); + if (size !== undefined) searchParams.append('size', String(size)); + + return await client.get('list', { searchParams }).json(); + }, upload: async (file: File) => { const formData = new FormData(); formData.append('file', file); diff --git a/src/routes/api/[...path]/index.tsx b/src/routes/api/[...path]/index.tsx index 170201c..5370287 100644 --- a/src/routes/api/[...path]/index.tsx +++ b/src/routes/api/[...path]/index.tsx @@ -1,7 +1,7 @@ import type { RequestEvent, RequestHandler } from '@builder.io/qwik-city'; const proxy = async ({ send, url, pathname, request }: RequestEvent) => { - const targetUrl = new URL(`http://localhost:8081${pathname}`, url); + const targetUrl = new URL(`http://localhost:8081${pathname}${url.search}`, url); const headers = new Headers(request.headers); const fetchOptions: RequestInit = { diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index 5197067..bc81ebd 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -1,4 +1,4 @@ -import { component$, Signal, useSignal, useTask$, useVisibleTask$ } from "@builder.io/qwik"; +import { $, component$, Signal, useSignal, useTask$, useVisibleTask$ } from "@builder.io/qwik"; import { routeLoader$, type DocumentHead } from "@builder.io/qwik-city"; import Actionbar from "~/components/dashboard/Actionbar"; import Settings from "~/components/dashboard/Settings"; @@ -35,7 +35,7 @@ export default component$(() => { - ); + ); }); const formatSize = (bytes: number) => { @@ -50,81 +50,96 @@ const Files = component$<{ files: Signal; loaded: Signal; }>(({ files }) => { - const File = component$(({ file }: { file: StereoFile }) => { - const Preview = component$(() => { - type FileType = "image" | "video" | "audio" | "other"; - const fileType: Signal = useSignal("other"); - const type = file.Mime.split("/")[1]; - useTask$(() => { - if (["jpeg", "jpg", "png", "gif", "webp"].includes(type)) fileType.value = "image"; - else if (["mp4", "webm", "ogg", "avi", "mov"].includes(type)) fileType.value = "video"; - else if (["mp3", "wav", "flac", "aac"].includes(type)) fileType.value = "audio"; - else fileType.value = "other"; - }); - return ( -
- {fileType.value === "image" && ( - // eslint-disable-next-line qwik/jsx-img - {file.Name} - )} - {fileType.value === "video" && ( -