From de9d1b4b74428293fd2e0e1d5651ceede0f89af5 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 1 May 2024 18:09:37 +0800 Subject: [PATCH] Feat(Menu): Support multi-platform Support add multi-platform tool to menu --- src/components/tools/RepositoryCard.tsx | 7 ++++- src/components/tools/StoreCard.tsx | 15 +++++++--- src/global.d.ts | 1 + src/pages/Tools/index.tsx | 1 + src/pages/ToolsFramework.tsx | 37 +++++++++++++++---------- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/components/tools/RepositoryCard.tsx b/src/components/tools/RepositoryCard.tsx index 31d57a1..656bcc4 100644 --- a/src/components/tools/RepositoryCard.tsx +++ b/src/components/tools/RepositoryCard.tsx @@ -12,6 +12,7 @@ interface RepositoryCardProps toolName: string toolId: string ver: string + platform: Platform options?: TiltOptions onOpen?: () => void onEdit?: () => void @@ -29,6 +30,7 @@ const RepositoryCard = ({ toolName, toolId, ver, + platform, options = { reverse: true, max: 8, @@ -52,7 +54,10 @@ const RepositoryCard = ({ }, [options]) return ( - + ) => { e.stopPropagation() - navigateToView(navigate, author.username, toolId, platform) + navigateToView(navigate, author.username, toolId, 'WEB') } return ( <> { const handleOnDragEnd = ({ active, over }: DragEndEvent) => { if (over && active.id !== over?.id) { const activeIndex = toolMenuItem.findIndex( - ({ authorUsername, toolId, ver }) => - `${authorUsername}:${toolId}:${ver}` === active.id + ({ authorUsername, toolId, ver, platform }) => + `${authorUsername}:${toolId}:${ver}:${platform}` === active.id ) const overIndex = toolMenuItem.findIndex( - ({ authorUsername, toolId, ver }) => - `${authorUsername}:${toolId}:${ver}` === over.id + ({ authorUsername, toolId, ver, platform }) => + `${authorUsername}:${toolId}:${ver}:${platform}` === over.id ) setToolMenuItem(arrayMove(toolMenuItem, activeIndex, overIndex)) } @@ -47,8 +47,8 @@ const ToolsFramework = () => { if (!over) { setToolMenuItem( toolMenuItem.filter( - ({ authorUsername, toolId, ver }) => - `${authorUsername}:${toolId}:${ver}` !== active?.id + ({ authorUsername, toolId, ver, platform }) => + `${authorUsername}:${toolId}:${ver}:${platform}` !== active?.id ) ) } @@ -63,7 +63,12 @@ const ToolsFramework = () => { ver === newItem.ver ) === -1 ) { - setToolMenuItem([...toolMenuItem, newItem]) + if (!checkDesktop() && newItem.platform === 'DESKTOP') { + void message.warning('暂不支持添加桌面端应用') + setToolMenuItem(toolMenuItem) + } else { + setToolMenuItem([...toolMenuItem, newItem]) + } } } @@ -110,8 +115,8 @@ const ToolsFramework = () => { - `${authorUsername}:${toolId}:${ver}` + ({ authorUsername, toolId, ver, platform }) => + `${authorUsername}:${toolId}:${ver}:${platform}` )} > {toolMenuItem.map( @@ -120,16 +125,18 @@ const ToolsFramework = () => { toolName, toolId, authorUsername, - ver + ver, + platform }) => ( @@ -137,12 +144,12 @@ const ToolsFramework = () => { path={getViewPath( authorUsername, toolId, - import.meta.env.VITE_PLATFORM, + platform, ver )} icon={icon} text={toolName} - key={`${authorUsername}:${toolId}`} + key={`${authorUsername}:${toolId}:${ver}:${platform}`} extend={} />