Skip to content

Commit

Permalink
🐛 fix(slots): 修复nav是外链时的跳转bug
Browse files Browse the repository at this point in the history
  • Loading branch information
史少飞 committed Apr 3, 2024
1 parent d5f1687 commit 7f0cc34
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 7f0cc34

Please sign in to comment.