-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5284dd
commit 75bae13
Showing
3 changed files
with
55 additions
and
9 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,47 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export function genBreadcrumbItems(pathname:string) { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const nav = useNavigate(); | ||
console.log(pathname); | ||
if (pathname.includes('overview')) { | ||
return [ | ||
{ | ||
title: <span className={'cursor-pointer'}>Project</span>, | ||
onClick() { | ||
nav('/project'); | ||
}, | ||
}, | ||
{ | ||
title: 'Overview', | ||
}, | ||
]; | ||
} else if (pathname.includes('commits')) { | ||
return [ | ||
{ | ||
title: <span className={'cursor-pointer'}>Project</span>, | ||
onClick() { | ||
nav('/project'); | ||
}, | ||
}, | ||
{ | ||
title: <span className={'cursor-pointer'}>Overview</span>, | ||
onClick() { | ||
const regex = /\/project\/(\d+)\//; | ||
const match = pathname.match(regex); | ||
if (match) { | ||
const projectId = match[1]; | ||
nav(`/project/${projectId}/overview`); | ||
} else { | ||
console.log('未找到匹配的项目ID'); | ||
} | ||
}, | ||
}, | ||
{ | ||
title: 'Coverage Details', | ||
}, | ||
]; | ||
} else { | ||
return []; | ||
} | ||
} |
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