Skip to content

Commit 6b0fffb

Browse files
committed
feat: add quick search button in navbar
1 parent 0b9233d commit 6b0fffb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { NavbarNavItem } from './NavItem';
3+
import { t } from 'tailchat-shared';
4+
import { Icon } from 'tailchat-design';
5+
import { openQuickSwitcher } from '@/components/QuickSwitcher';
6+
7+
export const QuickSwitcherNav: React.FC = React.memo(() => {
8+
return (
9+
<NavbarNavItem
10+
className="bg-gray-700"
11+
name={t('快速搜索、跳转') + ' | ctrl + k'}
12+
onClick={() => {
13+
openQuickSwitcher();
14+
}}
15+
data-testid="search"
16+
>
17+
<Icon className="text-3xl text-white" icon="mdi:search" />
18+
</NavbarNavItem>
19+
);
20+
});
21+
QuickSwitcherNav.displayName = 'QuickSwitcherNav';

client/web/src/routes/Main/Navbar/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { InstallBtn } from './InstallBtn';
99
import { ReactQueryDevBtn } from './ReactQueryDevBtn';
1010
import { pluginCustomPanel } from '@/plugin/common';
1111
import { NavbarCustomNavItem } from './CustomNavItem';
12+
import { QuickSwitcherNav } from './QuickSwitcherNav';
1213

1314
/**
1415
* 导航栏组件
@@ -28,6 +29,8 @@ export const Navbar: React.FC = React.memo(() => {
2829

2930
<InboxNav />
3031

32+
<QuickSwitcherNav />
33+
3134
{pluginCustomPanel
3235
.filter((p) => p.position === 'navbar-personal')
3336
.map((p) => (

client/web/src/routes/Main/useShortcuts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { isQuickSwitcher } from '@/utils/hot-key';
88
export function useShortcuts() {
99
useGlobalKeyDown((e) => {
1010
if (isQuickSwitcher(e)) {
11-
// 显示快速开关
11+
// 显示快速跳转开关
12+
e.preventDefault();
1213
openQuickSwitcher();
1314
}
1415
});

0 commit comments

Comments
 (0)