mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
파일 업로드/다운로드 현황을 모두 볼 수 있는 페이지 구현
This commit is contained in:
@@ -174,6 +174,10 @@ export const uploadFile = async (
|
||||
value.status = "canceled";
|
||||
return value;
|
||||
});
|
||||
fileUploadStatusStore.update((value) => {
|
||||
value = value.filter((v) => v !== status);
|
||||
return value;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,3 +20,10 @@ export const formatFileSize = (size: number) => {
|
||||
if (size < 1024 * 1024 * 1024) return `${(size / 1024 / 1024).toFixed(1)} MiB`;
|
||||
return `${(size / 1024 / 1024 / 1024).toFixed(1)} GiB`;
|
||||
};
|
||||
|
||||
export const formatNetworkSpeed = (speed: number) => {
|
||||
if (speed < 1000) return `${speed} bps`;
|
||||
if (speed < 1000 * 1000) return `${(speed / 1000).toFixed(1)} kbps`;
|
||||
if (speed < 1000 * 1000 * 1000) return `${(speed / 1000 / 1000).toFixed(1)} Mbps`;
|
||||
return `${(speed / 1000 / 1000 / 1000).toFixed(1)} Gbps`;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
export interface FileUploadStatus {
|
||||
name: string;
|
||||
parentId: "root" | number;
|
||||
@@ -34,3 +35,15 @@ export interface FileDownloadStatus {
|
||||
export const fileUploadStatusStore = writable<Writable<FileUploadStatus>[]>([]);
|
||||
|
||||
export const fileDownloadStatusStore = writable<Writable<FileDownloadStatus>[]>([]);
|
||||
|
||||
export const isFileUploading = (
|
||||
status: FileUploadStatus["status"],
|
||||
): status is "encryption-pending" | "encrypting" | "upload-pending" | "uploading" => {
|
||||
return ["encryption-pending", "encrypting", "upload-pending", "uploading"].includes(status);
|
||||
};
|
||||
|
||||
export const isFileDownloading = (
|
||||
status: FileDownloadStatus["status"],
|
||||
): status is "download-pending" | "downloading" | "decryption-pending" | "decrypting" => {
|
||||
return ["download-pending", "downloading", "decryption-pending", "decrypting"].includes(status);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user