mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-12 21:08:46 +00:00
파일 페이지에서 뷰어 로딩 메세지를 더 빠르게 표시하도록 개선
This commit is contained in:
@@ -42,14 +42,7 @@
|
||||
let viewerType: "image" | "video" | undefined = $state();
|
||||
let fileBlobUrl: string | undefined = $state();
|
||||
|
||||
const updateViewer = async (info: FileInfo, buffer: ArrayBuffer) => {
|
||||
const contentType = info.contentType;
|
||||
if (contentType.startsWith("image")) {
|
||||
viewerType = "image";
|
||||
} else if (contentType.startsWith("video")) {
|
||||
viewerType = "video";
|
||||
}
|
||||
|
||||
const updateViewer = async (buffer: ArrayBuffer, contentType: string) => {
|
||||
const fileBlob = new Blob([buffer], { type: contentType });
|
||||
if (contentType === "image/heic") {
|
||||
const { default: heic2any } = await import("heic2any");
|
||||
@@ -89,11 +82,18 @@
|
||||
|
||||
$effect(() => {
|
||||
if ($info && $info.dataKey && $info.contentIv) {
|
||||
const contentType = $info.contentType;
|
||||
if (contentType.startsWith("image")) {
|
||||
viewerType = "image";
|
||||
} else if (contentType.startsWith("video")) {
|
||||
viewerType = "video";
|
||||
}
|
||||
|
||||
untrack(() => {
|
||||
if (!downloadStatus && !isDownloadRequested) {
|
||||
isDownloadRequested = true;
|
||||
requestFileDownload(data.id, $info.contentIv!, $info.dataKey!).then(async (buffer) => {
|
||||
const blob = await updateViewer($info, buffer);
|
||||
const blob = await updateViewer(buffer, contentType);
|
||||
if (!viewerType) {
|
||||
FileSaver.saveAs(blob, $info.name);
|
||||
}
|
||||
@@ -105,7 +105,9 @@
|
||||
|
||||
$effect(() => {
|
||||
if ($info && $downloadStatus?.status === "decrypted") {
|
||||
untrack(() => !isDownloadRequested && updateViewer($info, $downloadStatus.result!));
|
||||
untrack(
|
||||
() => !isDownloadRequested && updateViewer($downloadStatus.result!, $info.contentType),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user