From 6792bed4bb6564fd3adf58d6a857e65d797def31 Mon Sep 17 00:00:00 2001 From: fishshi <2855691008@qq.com> Date: Tue, 17 Dec 2024 15:21:41 +0800 Subject: [PATCH] Move Dialog to automatically close CollectionCM --- .../components/Showcase/CollectionPage.tsx | 2 +- .../src/components/Showcase/Collections.tsx | 2 +- .../Showcase/posters/CollectionPoster.tsx | 14 +-- .../contextMenu/CollectionCM/main.tsx | 112 +++++++++--------- 4 files changed, 64 insertions(+), 66 deletions(-) diff --git a/src/renderer/src/components/Showcase/CollectionPage.tsx b/src/renderer/src/components/Showcase/CollectionPage.tsx index 46937ef..50c8564 100644 --- a/src/renderer/src/components/Showcase/CollectionPage.tsx +++ b/src/renderer/src/components/Showcase/CollectionPage.tsx @@ -35,7 +35,7 @@ export function CollectionPage(): JSX.Element { 'flex-shrink-0' // Preventing compression )} > - + ))} diff --git a/src/renderer/src/components/Showcase/Collections.tsx b/src/renderer/src/components/Showcase/Collections.tsx index 5b09b6e..3bbf16d 100644 --- a/src/renderer/src/components/Showcase/Collections.tsx +++ b/src/renderer/src/components/Showcase/Collections.tsx @@ -66,7 +66,7 @@ export function Collections(): JSX.Element { 'flex-shrink-0' // Preventing compression )} > - + ))} diff --git a/src/renderer/src/components/Showcase/posters/CollectionPoster.tsx b/src/renderer/src/components/Showcase/posters/CollectionPoster.tsx index 245bb6a..76f2f9d 100644 --- a/src/renderer/src/components/Showcase/posters/CollectionPoster.tsx +++ b/src/renderer/src/components/Showcase/posters/CollectionPoster.tsx @@ -6,19 +6,19 @@ import { CollectionCM } from '~/components/contextMenu/CollectionCM' import { GameImage } from '@ui/game-image' export function CollectionPoster({ - collctionId, + collectionId, className }: { - collctionId: string + collectionId: string className?: string }): JSX.Element { const navigate = useNavigate() const { collections } = useCollections() - const collectionName = collections[collctionId].name - const gameId = collections[collctionId].games[0] - const length = collections[collctionId].games.length + const collectionName = collections[collectionId].name + const gameId = collections[collectionId].games[0] + const length = collections[collectionId].games.length return ( - +
navigate(`/library/collections/${collctionId}`)} + onClick={() => navigate(`/library/collections/${collectionId}`)} > {/* background mask layer */}
('') - const [isOpen, setIsOpen] = useState(false) + const [isRenaming, setisRenaming] = useState(false) + const [isDeleting, setisDeleting] = useState(false) useEffect(() => { if (collections[collectionId].name !== newName) { @@ -43,67 +43,65 @@ export function CollectionCM({ return ( {children} + - - - setisRenaming(true)}>重命名 + + setisDeleting(true)}>删除 + + + + + { + setNewName(e.target.value) + }} + /> + + + + + + + + + 删除收藏 + + {`确定要删除收藏 ${collections[collectionId].name} 吗?`} + + { - setIsOpen(true) + setisDeleting(false) }} - onSelect={(e) => e.preventDefault()} > - 重命名 - - - - { - setNewName(e.target.value) - }} - /> - - - - - - - - e.preventDefault()}>删除 - - - - 删除收藏 - - {`确定要删除收藏 ${collections[collectionId].name} 吗?`} - - 取消 - { - removeCollection(collectionId) - }} - > - 确定 - - - - - + + + + ) }