mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-14 22:08:45 +00:00
브라우저에서 HEIF 이미지를 제대로 표현하지 못하던 버그 수정
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
"eslint-plugin-tailwindcss": "^3.17.5",
|
"eslint-plugin-tailwindcss": "^3.17.5",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"globals": "^15.0.0",
|
"globals": "^15.0.0",
|
||||||
|
"heic2any": "^0.0.4",
|
||||||
"mime": "^4.0.6",
|
"mime": "^4.0.6",
|
||||||
"prettier": "^3.3.2",
|
"prettier": "^3.3.2",
|
||||||
"prettier-plugin-svelte": "^3.2.6",
|
"prettier-plugin-svelte": "^3.2.6",
|
||||||
|
|||||||
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
@@ -88,6 +88,9 @@ devDependencies:
|
|||||||
globals:
|
globals:
|
||||||
specifier: ^15.0.0
|
specifier: ^15.0.0
|
||||||
version: 15.14.0
|
version: 15.14.0
|
||||||
|
heic2any:
|
||||||
|
specifier: ^0.0.4
|
||||||
|
version: 0.0.4
|
||||||
mime:
|
mime:
|
||||||
specifier: ^4.0.6
|
specifier: ^4.0.6
|
||||||
version: 4.0.6
|
version: 4.0.6
|
||||||
@@ -2415,6 +2418,10 @@ packages:
|
|||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/heic2any@0.0.4:
|
||||||
|
resolution: {integrity: sha512-3lLnZiDELfabVH87htnRolZ2iehX9zwpRyGNz22GKXIu0fznlblf0/ftppXKNqS26dqFSeqfIBhAmAj/uSp0cA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/ieee754@1.2.1:
|
/ieee754@1.2.1:
|
||||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FileSaver from "file-saver";
|
import FileSaver from "file-saver";
|
||||||
|
import heic2any from "heic2any";
|
||||||
import { untrack } from "svelte";
|
import { untrack } from "svelte";
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import { TopBar } from "$lib/components";
|
import { TopBar } from "$lib/components";
|
||||||
@@ -14,7 +15,8 @@
|
|||||||
let info: Writable<FileInfo | null> | undefined = $state();
|
let info: Writable<FileInfo | null> | undefined = $state();
|
||||||
let isDownloaded = $state(false);
|
let isDownloaded = $state(false);
|
||||||
|
|
||||||
let content: ArrayBuffer | undefined = $state();
|
let content: Blob | undefined = $state();
|
||||||
|
let contentUrl: string | undefined = $state();
|
||||||
let contentType: ContentType | undefined = $state();
|
let contentType: ContentType | undefined = $state();
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -30,14 +32,21 @@
|
|||||||
untrack(() => {
|
untrack(() => {
|
||||||
isDownloaded = true;
|
isDownloaded = true;
|
||||||
|
|
||||||
if ($info.contentType.startsWith("image/")) {
|
requestFileDownload(data.id, $info.contentIv, $info.dataKey).then(async (res) => {
|
||||||
contentType = "image";
|
content = new Blob([res], { type: $info.contentType });
|
||||||
} else if ($info.contentType.startsWith("video/")) {
|
if (content.type === "image/heic" || content.type === "image/heif") {
|
||||||
contentType = "video";
|
contentUrl = URL.createObjectURL(
|
||||||
}
|
(await heic2any({ blob: content, toType: "image/jpeg" })) as Blob,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
contentUrl = URL.createObjectURL(content);
|
||||||
|
}
|
||||||
|
|
||||||
requestFileDownload(data.id, $info.contentIv, $info.dataKey).then((res) => {
|
if (content.type.startsWith("image")) {
|
||||||
content = res;
|
contentType = "image";
|
||||||
|
} else if (content.type.startsWith("video")) {
|
||||||
|
contentType = "video";
|
||||||
|
}
|
||||||
|
|
||||||
if (!contentType) {
|
if (!contentType) {
|
||||||
FileSaver.saveAs(new Blob([res], { type: $info.contentType }), $info.name);
|
FileSaver.saveAs(new Blob([res], { type: $info.contentType }), $info.name);
|
||||||
@@ -46,6 +55,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
return () => {
|
||||||
|
if (contentUrl) {
|
||||||
|
URL.revokeObjectURL(contentUrl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { error } from "@sveltejs/kit";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import type { PageLoad } from "./$types";
|
import type { PageLoad } from "./$types";
|
||||||
|
|
||||||
|
export const ssr = false; // Because of heic2any
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params }) => {
|
export const load: PageLoad = async ({ params }) => {
|
||||||
const zodRes = z
|
const zodRes = z
|
||||||
.object({
|
.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user