DeekSeekHome.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. const userInfo = localStorage.getItem('userInfo');
  40. if (userInfo) {
  41. init();
  42. }
  43. }, []);
  44. return (
  45. <Spin spinning={listLoading}>
  46. <div className='deekSeek'>
  47. <div className='deekSeek-header' style={{ justifyContent: isMobileScreen ? 'flex-start' : 'center' }}>
  48. <div style={{ display: 'flex', alignItems: 'center', margin: '0 20px' }}>
  49. <img src={whiteLogo.src} style={{ width: 20, marginRight: 10 }} />
  50. <div style={{ whiteSpace: 'nowrap' }}>
  51. 上海建科
  52. </div>
  53. </div>
  54. {
  55. list.map((item, index) => {
  56. return <Dropdown
  57. menu={{
  58. items: item.children.map((child, i) => {
  59. return {
  60. key: i,
  61. label: child.title,
  62. onClick: () => {
  63. const search = `?showMenu=${child.showMenu}&chatMode=${child.chatMode}&appId=${child.appId}`;
  64. navigate({
  65. pathname: '/knowledgeChat',
  66. search: search,
  67. })
  68. },
  69. };
  70. })
  71. }}
  72. key={index}
  73. >
  74. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }}>
  75. {item.title}
  76. </div>
  77. </Dropdown>
  78. })
  79. }
  80. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }} onClick={() => {
  81. navigate({
  82. pathname: '/deepseekChat',
  83. })
  84. }}>
  85. DeepSeek问答
  86. </div>
  87. </div>
  88. <div className='deekSeek-content'>
  89. <div className='deekSeek-content-title'>
  90. <img src={jkxz.src} />
  91. </div>
  92. <div className='deekSeek-content-title-sm' style={{ marginBottom: isMobileScreen ? 14 : 36 }}>
  93. 智能问答助手
  94. </div>
  95. <div className={isMobileScreen ? 'deekSeek-content-mobile' : 'deekSeek-content-pc'}>
  96. <Chat />
  97. </div>
  98. </div>
  99. </div>
  100. </Spin>
  101. );
  102. };
  103. export default DeekSeek;