Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.tsx 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { ReactComponent as StarIon } from '@/assets/svg/chat-star.svg';
  2. import { ReactComponent as Logo } from '@/assets/svg/logo.svg';
  3. import { Layout, Radio, Space, theme } from 'antd';
  4. import styles from './index.less';
  5. import { useMemo } from 'react';
  6. import { useLocation, useNavigate } from 'umi';
  7. import User from '../user';
  8. const { Header } = Layout;
  9. const RagHeader = () => {
  10. const {
  11. token: { colorBgContainer },
  12. } = theme.useToken();
  13. const navigate = useNavigate();
  14. const { pathname } = useLocation();
  15. const tagsData = [
  16. { path: '/knowledge', name: 'knowledge' },
  17. { path: '/chat', name: 'chat' },
  18. { path: '/file', name: 'file' },
  19. ];
  20. const currentPath = useMemo(() => {
  21. return tagsData.find((x) => x.path === pathname)?.name || 'knowledge';
  22. }, [pathname]);
  23. const handleChange = (path: string) => {
  24. navigate(path);
  25. };
  26. return (
  27. <Header
  28. style={{
  29. padding: '0 16px',
  30. background: colorBgContainer,
  31. display: 'flex',
  32. justifyContent: 'space-between',
  33. alignItems: 'center',
  34. height: '72px',
  35. }}
  36. >
  37. <Space size={12}>
  38. <Logo className={styles.appIcon}></Logo>
  39. <label className={styles.appName}>Infinity flow</label>
  40. </Space>
  41. <Space size={[0, 8]} wrap>
  42. <Radio.Group
  43. defaultValue="a"
  44. buttonStyle="solid"
  45. className={styles.radioGroup}
  46. value={currentPath}
  47. >
  48. {tagsData.map((item) => (
  49. <Radio.Button
  50. value={item.name}
  51. onClick={() => handleChange(item.path)}
  52. >
  53. <Space>
  54. <StarIon className={styles.radioButtonIcon}></StarIon>
  55. {item.name}
  56. </Space>
  57. </Radio.Button>
  58. ))}
  59. </Radio.Group>
  60. </Space>
  61. <User></User>
  62. </Header>
  63. );
  64. };
  65. export default RagHeader;