Skip to content

Commit

Permalink
feat: add quick search button in navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Apr 5, 2024
1 parent 0b9233d commit 6b0fffb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
21 changes: 21 additions & 0 deletions client/web/src/routes/Main/Navbar/QuickSwitcherNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { NavbarNavItem } from './NavItem';
import { t } from 'tailchat-shared';
import { Icon } from 'tailchat-design';
import { openQuickSwitcher } from '@/components/QuickSwitcher';

export const QuickSwitcherNav: React.FC = React.memo(() => {
return (
<NavbarNavItem
className="bg-gray-700"
name={t('快速搜索、跳转') + ' | ctrl + k'}
onClick={() => {
openQuickSwitcher();
}}
data-testid="search"
>
<Icon className="text-3xl text-white" icon="mdi:search" />
</NavbarNavItem>
);
});
QuickSwitcherNav.displayName = 'QuickSwitcherNav';
3 changes: 3 additions & 0 deletions client/web/src/routes/Main/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { InstallBtn } from './InstallBtn';
import { ReactQueryDevBtn } from './ReactQueryDevBtn';
import { pluginCustomPanel } from '@/plugin/common';
import { NavbarCustomNavItem } from './CustomNavItem';
import { QuickSwitcherNav } from './QuickSwitcherNav';

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

<InboxNav />

<QuickSwitcherNav />

{pluginCustomPanel
.filter((p) => p.position === 'navbar-personal')
.map((p) => (
Expand Down
3 changes: 2 additions & 1 deletion client/web/src/routes/Main/useShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { isQuickSwitcher } from '@/utils/hot-key';
export function useShortcuts() {
useGlobalKeyDown((e) => {
if (isQuickSwitcher(e)) {
// 显示快速开关
// 显示快速跳转开关
e.preventDefault();
openQuickSwitcher();
}
});
Expand Down

0 comments on commit 6b0fffb

Please sign in to comment.