파일 업로드가 완료된 후에 파일/디렉터리 목록이 갱신되지 않던 버그 수정 및 구현되지 않은 탭 임시 레이아웃 구현

This commit is contained in:
static
2025-01-07 01:25:14 +09:00
parent 7a1bf80a12
commit 661e7a33de
12 changed files with 61 additions and 34 deletions

View File

@@ -2,7 +2,7 @@ import { redirect } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async ({ url, cookies }) => {
const redirectPath = url.searchParams.get("redirect") || "/";
const redirectPath = url.searchParams.get("redirect") || "/home";
const accessToken = cookies.get("accessToken");
if (accessToken) {

View File

@@ -1,6 +1,6 @@
import type { PageLoad } from "./$types";
export const load: PageLoad = async ({ url }) => {
const redirectPath = url.searchParams.get("redirect") || "/";
const redirectPath = url.searchParams.get("redirect") || "/home";
return { redirectPath };
};

View File

@@ -1,6 +1,6 @@
import type { PageLoad } from "./$types";
export const load: PageLoad = async ({ url }) => {
const redirectPath = url.searchParams.get("redirect") || "/";
const redirectPath = url.searchParams.get("redirect") || "/home";
return { redirectPath };
};

View File

@@ -1,4 +1,5 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { page } from "$app/state";
import { AdaptiveDiv } from "$lib/components/divs";
@@ -26,7 +27,10 @@
<div class="flex w-full justify-evenly px-4 py-2">
{#each pages as { path, label, icon: Icon }}
{@const textColor = !page.url.pathname.startsWith(path) ? "text-gray-600" : ""}
<button class="w-16 active:rounded-xl active:bg-gray-100 {textColor}">
<button
onclick={() => goto(path)}
class="w-16 active:rounded-xl active:bg-gray-100 {textColor}"
>
<div class="gap-y flex flex-col items-center gap-y-1 p-1 transition active:scale-95">
<Icon class="text-xl" fill="0" />
<p class="text-sm">{label}</p>

View File

@@ -0,0 +1,3 @@
<div class="flex h-full items-center justify-center py-4">
<p class="text-gray-500">아직 개발 중이에요.</p>
</div>

View File

@@ -52,6 +52,6 @@
</div>
{:else}
<div class="my-4 flex flex-grow items-center justify-center">
<p class="text-gray-500">폴더가 비어있어요.</p>
<p class="text-gray-500">폴더가 비어 있어요.</p>
</div>
{/if}

View File

@@ -39,35 +39,42 @@ export const requestDirectoryCreation = async (
});
};
export const requestFileUpload = async (
file: File,
parentId: "root" | number,
masterKey: MasterKey,
) => {
const { dataKey, dataKeyVersion } = await generateDataKey();
const fileEncrypted = await encryptData(await file.arrayBuffer(), dataKey);
const nameEncrypted = await encryptString(file.name, dataKey);
export const requestFileUpload = (file: File, parentId: "root" | number, masterKey: MasterKey) => {
return new Promise<void>(async (resolve, reject) => {
const { dataKey, dataKeyVersion } = await generateDataKey();
const fileEncrypted = await encryptData(await file.arrayBuffer(), dataKey);
const nameEncrypted = await encryptString(file.name, dataKey);
const form = new FormData();
form.set(
"metadata",
JSON.stringify({
parentId,
mekVersion: masterKey.version,
dek: await wrapDataKey(dataKey, masterKey.key),
dekVersion: dataKeyVersion,
contentType: file.type,
contentIv: fileEncrypted.iv,
name: nameEncrypted.ciphertext,
nameIv: nameEncrypted.iv,
} satisfies FileUploadRequest),
);
form.set("content", new Blob([fileEncrypted.ciphertext]));
const form = new FormData();
form.set(
"metadata",
JSON.stringify({
parentId,
mekVersion: masterKey.version,
dek: await wrapDataKey(dataKey, masterKey.key),
dekVersion: dataKeyVersion,
contentType: file.type,
contentIv: fileEncrypted.iv,
name: nameEncrypted.ciphertext,
nameIv: nameEncrypted.iv,
} satisfies FileUploadRequest),
);
form.set("content", new Blob([fileEncrypted.ciphertext]));
// TODO: Progress, Scheduling, ...
const xhr = new XMLHttpRequest();
xhr.open("POST", "/api/file/upload");
xhr.send(form);
// TODO: Progress, Scheduling, ...
const xhr = new XMLHttpRequest();
xhr.addEventListener("load", () => {
if (xhr.status === 200) {
resolve();
} else {
reject(new Error(xhr.responseText));
}
});
xhr.open("POST", "/api/file/upload");
xhr.send(form);
});
};
export const requestDirectoryEntryRename = async (

View File

@@ -0,0 +1,3 @@
<div class="flex h-full items-center justify-center py-4">
<p class="text-gray-500">아직 개발 중이에요.</p>
</div>

View File

@@ -0,0 +1,3 @@
<div class="flex h-full items-center justify-center py-4">
<p class="text-gray-500">아직 개발 중이에요.</p>
</div>

View File

@@ -0,0 +1,3 @@
<div class="flex h-full items-center justify-center py-4">
<p class="text-gray-500">아직 개발 중이에요.</p>
</div>

View File

@@ -1,2 +0,0 @@
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>

6
src/routes/+server.ts Normal file
View File

@@ -0,0 +1,6 @@
import { redirect } from "@sveltejs/kit";
import type { RequestHandler } from "./$types";
export const GET: RequestHandler = () => {
redirect(302, "/home");
};