mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
홈 페이지와 갤러리 페이지에서 사진 및 동영상만 표시되도록 개선
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
|
||||
let { files, onFileClick }: Props = $props();
|
||||
|
||||
type FileEntry = { date?: Date; info: Writable<FileInfo | null> };
|
||||
type FileEntry =
|
||||
| { date?: undefined; contentType?: undefined; info: Writable<FileInfo | null> }
|
||||
| { date: Date; contentType: string; info: Writable<FileInfo | null> };
|
||||
type Row =
|
||||
| { type: "header"; key: string; label: string }
|
||||
| { type: "items"; key: string; items: FileEntry[] };
|
||||
@@ -37,15 +39,28 @@
|
||||
|
||||
$effect(() => {
|
||||
filesWithDate = files.map((file) => {
|
||||
const { createdAt, lastModifiedAt } = get(file) ?? {};
|
||||
return { date: createdAt ?? lastModifiedAt, info: file };
|
||||
const info = get(file);
|
||||
if (info) {
|
||||
return {
|
||||
date: info.createdAt ?? info.lastModifiedAt,
|
||||
contentType: info.contentType,
|
||||
info: file,
|
||||
};
|
||||
} else {
|
||||
return { info: file };
|
||||
}
|
||||
});
|
||||
|
||||
const buildRows = () => {
|
||||
const map = new Map<string, FileEntry[]>();
|
||||
|
||||
for (const file of filesWithDate) {
|
||||
if (!file.date) continue;
|
||||
if (
|
||||
!file.date ||
|
||||
!(file.contentType.startsWith("image/") || file.contentType.startsWith("video/"))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const date = formatDateSortable(file.date);
|
||||
const entries = map.get(date) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user