-
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
11 changed files
with
262 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { PropsWithChildren } from 'react' | ||
|
||
export const metadata = { | ||
title: '项目详情', | ||
} | ||
export default function Page(props: PropsWithChildren) { | ||
return props.children | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client' | ||
|
||
import { useQuery } from '@tanstack/react-query' | ||
import { useEffect } from 'react' | ||
import { useParams, useRouter } from 'next/navigation' | ||
|
||
import { NotFound404 } from '~/components/common/404' | ||
import { Loading } from '~/components/ui/loading' | ||
import { apiClient } from '~/utils/request' | ||
|
||
export default function Page() { | ||
const { id } = useParams() | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: [id, 'project'], | ||
queryFn: async ({ queryKey }) => { | ||
const [id] = queryKey | ||
return apiClient.project.getById(id) | ||
}, | ||
}) | ||
const router = useRouter() | ||
useEffect(() => { | ||
if (data?.projectUrl) { | ||
window.open(data.projectUrl) | ||
router.back() | ||
} | ||
}, [data?.projectUrl]) | ||
|
||
if (isLoading) { | ||
return <Loading useDefaultLoadingText /> | ||
} | ||
|
||
if (!data) { | ||
return <NotFound404 /> | ||
} | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Metadata } from 'next' | ||
import type { PropsWithChildren } from 'react' | ||
|
||
import { WiderContainer } from '~/components/layout/container/Wider' | ||
|
||
export const metadata: Metadata = { | ||
title: '项目', | ||
} | ||
export default async function Layout(props: PropsWithChildren) { | ||
return <WiderContainer>{props.children}</WiderContainer> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use client' | ||
|
||
import { useQuery } from '@tanstack/react-query' | ||
|
||
import { CodiconGithubInverted } from '~/components/icons/menu-collection' | ||
import { Loading } from '~/components/ui/loading' | ||
import { BottomToUpTransitionView } from '~/components/ui/transition/BottomToUpTransitionView' | ||
import { ProjectList } from '~/components/widgets/project/ProjectList' | ||
import { NothingFound } from '~/components/widgets/shared/NothingFound' | ||
import { noopArr } from '~/lib/noop' | ||
import { useAggregationSelector } from '~/providers/root/aggregation-data-provider' | ||
import { apiClient } from '~/utils/request' | ||
|
||
export default function Page() { | ||
const { data, isLoading } = useQuery({ | ||
queryKey: ['projects'], | ||
queryFn: async () => { | ||
const data = await apiClient.project.getAll() | ||
return data.data | ||
}, | ||
}) | ||
|
||
const githubUsername = useAggregationSelector( | ||
(state) => state.user?.socialIds?.github, | ||
) | ||
|
||
if (isLoading) { | ||
return <Loading useDefaultLoadingText /> | ||
} | ||
|
||
if (!data) return <NothingFound /> | ||
|
||
return ( | ||
<div> | ||
<header className="prose"> | ||
<h1>项目们</h1> | ||
</header> | ||
|
||
<main className="mt-10"> | ||
<div className="my-12 inline-flex items-center text-3xl font-medium"> | ||
项目{' '} | ||
{githubUsername && ( | ||
<a | ||
href={`https://github.com/${githubUsername}`} | ||
className="ml-2 inline-flex !text-inherit" | ||
target="_blank" | ||
aria-label="view on GitHub" | ||
rel="noopener noreferrer" | ||
> | ||
<CodiconGithubInverted /> | ||
</a> | ||
)} | ||
</div> | ||
<BottomToUpTransitionView> | ||
<ProjectList projects={data || noopArr} /> | ||
</BottomToUpTransitionView> | ||
</main> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ImageLazy } from '~/components/ui/image' | ||
import { FlexText } from '~/components/ui/text' | ||
import { clsxm } from '~/utils/helper' | ||
|
||
export const ProjectIcon: Component<{ avatar?: string; name?: string }> = ( | ||
props, | ||
) => { | ||
const { avatar, name, className } = props | ||
return ( | ||
<div | ||
className={clsxm( | ||
'project-icon flex flex-shrink-0 flex-grow items-center justify-center rounded-xl', | ||
avatar | ||
? 'ring-2 ring-slate-200 dark:ring-neutral-800' | ||
: 'bg-slate-300 text-white dark:bg-neutral-800', | ||
'aspect-square rounded-md transition-all duration-300', | ||
className, | ||
)} | ||
> | ||
{avatar ? ( | ||
<ImageLazy | ||
className="aspect-square rounded-xl transition-shadow duration-300" | ||
src={avatar} | ||
/> | ||
) : ( | ||
<FlexText text={name?.charAt(0).toUpperCase() || ''} scale={0.5} /> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Link from 'next/link' | ||
import type { FC } from 'react' | ||
|
||
import { routeBuilder, Routes } from '~/lib/route-builder' | ||
|
||
import { ProjectIcon } from './ProjectIcon' | ||
|
||
export type Project = { | ||
id: string | ||
avatar?: string | ||
name: string | ||
description?: string | ||
} | ||
export const ProjectList: FC<{ projects: Project[] }> = (props) => { | ||
const projects = props.projects | ||
|
||
return ( | ||
<section key="list" className="text-center"> | ||
<div className="grid grid-cols-1 gap-12 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"> | ||
{projects.map((project) => { | ||
return ( | ||
<Link | ||
href={routeBuilder(Routes.Project, { id: project.id })} | ||
key={project.id} | ||
className="group grid grid-cols-[1fr_2fr] gap-4" | ||
> | ||
<ProjectIcon | ||
className="group-hover:-translate-y-2 group-hover:shadow-out-sm" | ||
avatar={project.avatar} | ||
name={project.name} | ||
/> | ||
<span className="flex flex-shrink-0 flex-grow flex-col gap-2 text-left"> | ||
<h4 className="font-2xl m-0 p-0 font-medium">{project.name}</h4> | ||
<span className="line-clamp-5 text-sm md:line-clamp-4 lg:line-clamp-2"> | ||
{project.description} | ||
</span> | ||
</span> | ||
</Link> | ||
) | ||
})} | ||
</div> | ||
</section> | ||
) | ||
} |
Oops, something went wrong.
c32a5a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shiro – ./
springtide.vercel.app
innei.in
shiro-innei.vercel.app
shiro-git-main-innei.vercel.app