feat: 重构 openInCNB 函数,简化代码逻辑并优化导航处理

This commit is contained in:
2026-02-27 02:29:11 +08:00
parent f05aab2430
commit 364e903d5f

View File

@@ -72,11 +72,16 @@ export function RepoCard({ showReturn = false, repo }: RepoCardProps) {
const handleIssue = (repo: any) => {
window.open(`https://cnb.cool/${repo.path}/-/issues`)
}
const handleSettings = (repo: any) => {
window.open(`https://cnb.cool/${repo.path}/-/settings`)
}
const openInCNB = (isDetail = true) => {
if (!showReturn && isDetail) {
navigate({ to: `/repo?repo=${repo.path}` })
} else {
window.open(`https://cnb.cool/${repo.path}`, '_blank')
}
}
return (
<>
<Card className="relative p-0 overflow-hidden border border-neutral-200 bg-white hover:shadow-xl hover:border-neutral-300 transition-all duration-300 group pb-14">
@@ -94,11 +99,7 @@ export function RepoCard({ showReturn = false, repo }: RepoCardProps) {
<div
className="text-lg font-bold text-neutral-900 hover:text-neutral-600 transition-colors line-clamp-1 group-hover:underline"
onClick={() => {
if (!showReturn) {
navigate({ to: `/repo?repo=${repo.path}` })
} else {
window.open(`https://cnb.cool/${repo.path}`, '_blank')
}
openInCNB()
}}
>
{repo.path}
@@ -299,10 +300,8 @@ export function RepoCard({ showReturn = false, repo }: RepoCardProps) {
)}
<Badge variant="outline" className="text-xs border-neutral-300 text-neutral-700 hover:bg-neutral-100 transition-colors">{repo.visibility_level}</Badge>
</div>
<div className={clsx("flex flex-col sm:flex-row sm:items-center gap-4", !showReturn && "cursor-pointer")} onClick={() => {
if (!showReturn) {
window.open(repo.site, '_blank')
}
<div className={clsx(!showReturn && "cursor-pointer")} onClick={() => {
{ !showReturn && openInCNB(false) }
}}>
{repo.site && (
<div