DeekSeekHome.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import * as React from 'react';
  2. import { useNavigate } from "react-router-dom";
  3. import { Dropdown, Spin } from 'antd';
  4. import { Chat } from './DeepSeekChat';
  5. import whiteLogo from "../icons/whiteLogo.png";
  6. import jkxz from "../icons/jkxz.png";
  7. import { useChatStore } from "../store";
  8. import { useMobileScreen } from '../utils';
  9. import api from "@/app/api/api";
  10. import './deepSeekHome.scss';
  11. const DeekSeek: React.FC = () => {
  12. const chatStore = useChatStore();
  13. const isMobileScreen = useMobileScreen();
  14. const navigate = useNavigate();
  15. const [listLoading, setListLoading] = React.useState(false);
  16. type List = {
  17. title: string,
  18. children: {
  19. title: string,
  20. showMenu: string,
  21. chatMode: string,
  22. appId: string,
  23. }[],
  24. }[];
  25. const [list, setList] = React.useState<List>([]);
  26. const init = async () => {
  27. setListLoading(true);
  28. try {
  29. const res = await api.get('/deepseek/api/appType');
  30. setList(res.data);
  31. } catch (error) {
  32. console.error(error);
  33. } finally {
  34. setListLoading(false);
  35. }
  36. }
  37. React.useEffect(() => {
  38. chatStore.clearSessions();
  39. init()
  40. }, []);
  41. return (
  42. <Spin spinning={listLoading}>
  43. <div className='deekSeek'>
  44. <div className='deekSeek-header' style={{ justifyContent: isMobileScreen ? 'flex-start' : 'center' }}>
  45. <div style={{ display: 'flex', alignItems: 'center', margin: '0 20px' }}>
  46. <img src={whiteLogo.src} style={{ width: 20, marginRight: 10 }} />
  47. <div style={{ whiteSpace: 'nowrap' }}>
  48. 上海建科
  49. </div>
  50. </div>
  51. {
  52. list.map((item, index) => {
  53. return <Dropdown
  54. menu={{
  55. items: item.children.map((child, i) => {
  56. return {
  57. key: i,
  58. label: child.title,
  59. onClick: () => {
  60. const search = `?showMenu=${child.showMenu}&chatMode=${child.chatMode}&appId=${child.appId}`;
  61. navigate({
  62. pathname: '/knowledgeChat',
  63. search: search,
  64. })
  65. },
  66. };
  67. })
  68. }}
  69. key={index}
  70. >
  71. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }}>
  72. {item.title}
  73. </div>
  74. </Dropdown>
  75. })
  76. }
  77. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }} onClick={() => {
  78. navigate({
  79. pathname: '/deepseekChat',
  80. })
  81. }}>
  82. DeepSeek问答
  83. </div>
  84. </div>
  85. <div className='deekSeek-content'>
  86. <div className='deekSeek-content-title'>
  87. <img src={jkxz.src} />
  88. </div>
  89. <div className='deekSeek-content-title-sm' style={{ marginBottom: isMobileScreen ? 14 : 36 }}>
  90. 智能问答助手
  91. </div>
  92. <div className={isMobileScreen ? 'deekSeek-content-mobile' : 'deekSeek-content-pc'}>
  93. <Chat />
  94. </div>
  95. </div>
  96. </div>
  97. </Spin>
  98. );
  99. };
  100. export default DeekSeek;