From 8a825affd0034f2b9aa153a979ed19fbffccbc5a Mon Sep 17 00:00:00 2001 From: HouKunLin Date: Tue, 16 May 2023 16:24:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=AD=8C=E6=9B=B2=E5=B0=81?= =?UTF-8?q?=E9=9D=A2=E4=BD=BF=E7=94=A8=20Image=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E6=AD=8C=E6=9B=B2=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E4=BD=BF=E7=94=A8=E4=B8=80=E4=B8=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E6=95=88=E6=9E=9C=E6=9D=A5=E8=BF=87=E6=B8=A1=E4=B8=80?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/file-listing/FileRow.tsx | 153 ++++++++++++++------------ 1 file changed, 83 insertions(+), 70 deletions(-) diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 07c04c3..9cdc12d 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -1,20 +1,22 @@ import { - Avatar, Box, Button, Card, CardBody, Center, + Collapse, Grid, GridItem, + Image, Link, Text, + useDisclosure, VStack, Wrap, WrapItem, } from '@chakra-ui/react'; -import { DecryptedAudioFile, ProcessState, deleteFile } from './fileListingSlice'; -import { useRef } from 'react'; +import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; +import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; interface FileRowProps { @@ -23,6 +25,7 @@ interface FileRowProps { } export function FileRow({ id, file }: FileRowProps) { + const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); const dispatch = useAppDispatch(); const isDecrypted = file.state === ProcessState.COMPLETE; @@ -30,7 +33,7 @@ export function FileRow({ id, file }: FileRowProps) { const decryptedName = nameWithoutExt + '.' + file.ext; const audioPlayerRef = useRef(null); - const togglePlay = () => { + const togglePlay = useCallback(() => { const player = audioPlayerRef.current; if (!player) { return; @@ -41,87 +44,97 @@ export function FileRow({ id, file }: FileRowProps) { } else { player.pause(); } - }; + }, []); - const handleDeleteRow = () => { - dispatch(deleteFile({ id })); - }; + const handleDeleteRow = useCallback(() => { + onToggle(); + setTimeout(() => { + dispatch(deleteFile({ id })); + }, 500); + }, [dispatch, id, onToggle]); return ( - - - + + + - -
- {file.metadata.cover && } - {!file.metadata.cover && 暂无封面} -
-
- - - {file.metadata.name || nameWithoutExt} - - - - {isDecrypted && ( - - 专辑: {file.metadata.album} - 艺术家: {file.metadata.artist} - 专辑艺术家: {file.metadata.albumArtist} + }} + gridTemplateRows={{ + base: 'repeat(auto-fill)', + md: 'min-content 1fr', + }} + gridTemplateColumns={{ + base: '1fr', + md: '160px 1fr', + }} + gap="1" + > + +
+ {file.metadata.album} +
+
+ + + {file.metadata.name || nameWithoutExt} - )} - - - - {file.decrypted && + + {isDecrypted && ( + + 专辑: {file.metadata.album} + 艺术家: {file.metadata.artist} + 专辑艺术家: {file.metadata.albumArtist} + + )} + + + + {file.decrypted && - -
-
-
+ + + +
+
+
+ ); } From 0197c8b2f45b923746d66067963d7c72f5ae7f64 Mon Sep 17 00:00:00 2001 From: HouKunLin Date: Wed, 17 May 2023 09:10:36 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E8=A1=8C=E6=95=B0=E6=8D=AE=E6=97=B6=E6=94=B9=E7=94=A8?= =?UTF-8?q?=20onClose=20=E6=9D=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/file-listing/FileRow.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 9cdc12d..2efe8d3 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -25,7 +25,7 @@ interface FileRowProps { } export function FileRow({ id, file }: FileRowProps) { - const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); + const { isOpen, onClose } = useDisclosure({ defaultIsOpen: true }); const dispatch = useAppDispatch(); const isDecrypted = file.state === ProcessState.COMPLETE; @@ -47,11 +47,11 @@ export function FileRow({ id, file }: FileRowProps) { }, []); const handleDeleteRow = useCallback(() => { - onToggle(); + onClose(); setTimeout(() => { dispatch(deleteFile({ id })); }, 500); - }, [dispatch, id, onToggle]); + }, [dispatch, id, onClose]); return ( From 4341203c08cf00504a78908b5195c99e04659698 Mon Sep 17 00:00:00 2001 From: HouKunLin Date: Wed, 17 May 2023 09:27:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20togglePlay=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BD=BF=E7=94=A8=20useCallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/file-listing/FileRow.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 4c5c5e9..b949e4e 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -18,7 +18,6 @@ import { import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; -import coverFallback from '~/assets/no-cover.svg'; interface FileRowProps { id: string; @@ -35,7 +34,7 @@ export function FileRow({ id, file }: FileRowProps) { const decryptedName = nameWithoutExt + '.' + file.ext; const audioPlayerRef = useRef(null); - const togglePlay = useCallback(() => { + const togglePlay = () => { const player = audioPlayerRef.current; if (!player) { return; @@ -46,7 +45,7 @@ export function FileRow({ id, file }: FileRowProps) { } else { player.pause(); } - }, []); + }; const handleDeleteRow = useCallback(() => { onClose(); @@ -89,7 +88,7 @@ export function FileRow({ id, file }: FileRowProps) { objectFit="cover" src={metadata.cover} alt={`"${metadata.album}" 的专辑封面`} - fallbackSrc={coverFallback} + fallbackSrc={'/assets/no-cover.svg'} /> )} From aaefffbb8b7716439940a1df5a352697adf595e1 Mon Sep 17 00:00:00 2001 From: HouKunLin Date: Wed, 17 May 2023 09:39:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E5=8D=B3=E4=BD=BF=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=AD=8C=E6=9B=B2=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E4=B9=9F=E5=B1=95=E7=A4=BA=E9=BB=98=E8=AE=A4=E7=9A=84?= =?UTF-8?q?=E2=80=9C=E6=9A=82=E6=97=A0=E5=B0=81=E9=9D=A2=E2=80=9D=E5=8D=A0?= =?UTF-8?q?=E4=BD=8D=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/file-listing/FileRow.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index b949e4e..6680b07 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -18,6 +18,7 @@ import { import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; +import coverSvgUrl from '~/assets/no-cover.svg'; interface FileRowProps { id: string; @@ -83,14 +84,12 @@ export function FileRow({ id, file }: FileRowProps) { >
- {metadata && ( - {`"${metadata.album}" - )} + {`${metadata?.album}