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