Skip to content

Commit

Permalink
Merge pull request #41 from xinlanlan/fix/navbar-link-fix
Browse files Browse the repository at this point in the history
🐛 fix(slots): 修复nav是外链时的跳转bug
  • Loading branch information
canisminor1990 authored Apr 8, 2024
2 parents d5f1687 + 7f0cc34 commit e7d9b9e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/slots/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TabsNav } from '@lobehub/ui';
import { createStyles } from 'antd-style';
import { Link, history } from 'dumi';
import { Link } from 'dumi';
import NavbarExtra from 'dumi/theme-default/slots/NavbarExtra';
import { memo } from 'react';
import { shallow } from 'zustand/shallow';
Expand Down Expand Up @@ -35,19 +35,16 @@ const Navbar = memo(() => {
className={styles.tabs}
items={nav.map((item) => ({
key: String(item.activePath! || item.link),
label: (
label: /^(\w+:)\/\/|^(mailto|tel):/.test(item.link) ? (
<a className={styles.link} href={String(item.link)} rel="noreferrer" target="_blank">
{item.title}
</a>
) : (
<Link className={styles.link} to={String(item.link)}>
{item.title}
</Link>
),
}))}
onChange={(path) => {
const url = nav.find((index) => index.activePath === path || index.link === path)?.link;

if (!url) return;

history.push(url);
}}
/>
<NavbarExtra />
</>
Expand Down

0 comments on commit e7d9b9e

Please sign in to comment.