DeekSeekHome.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. children: List[number]['children'],
  24. }[],
  25. }[];
  26. const [list, setList] = React.useState<List>([]);
  27. const init = async () => {
  28. setListLoading(true);
  29. try {
  30. const res = await api.get('/deepseek/api/appType');
  31. setList(res.data);
  32. } catch (error) {
  33. console.error(error);
  34. } finally {
  35. setListLoading(false);
  36. }
  37. }
  38. React.useEffect(() => {
  39. chatStore.clearSessions();
  40. const userInfo = localStorage.getItem('userInfo');
  41. if (userInfo) {
  42. init();
  43. }
  44. }, []);
  45. return (
  46. <Spin spinning={listLoading}>
  47. <div className='deekSeek'>
  48. <div className='deekSeek-header' style={{ justifyContent: isMobileScreen ? 'flex-start' : 'center' }}>
  49. <div style={{ display: 'flex', alignItems: 'center', margin: '0 20px' }}>
  50. <img src={whiteLogo.src} style={{ width: 20, marginRight: 10 }} />
  51. <div style={{ whiteSpace: 'nowrap' }}>
  52. 上海建科
  53. </div>
  54. </div>
  55. {
  56. list.map((item, index) => {
  57. return <Dropdown
  58. menu={{
  59. items: item.children.map((child, i) => {
  60. return {
  61. key: 'child' + i,
  62. label: <div
  63. onClick={() => {
  64. const search = `?showMenu=${child.showMenu}&chatMode=${child.chatMode}&appId=${child.appId}`;
  65. if (child.appId) {
  66. navigate({
  67. pathname: '/knowledgeChat',
  68. search: search,
  69. })
  70. }
  71. }}
  72. >
  73. {child.title}
  74. </div>,
  75. children: child.children ? child.children.map((record, ind) => {
  76. return {
  77. key: 'record' + ind,
  78. label: <div
  79. onClick={() => {
  80. const search = `?showMenu=${record.showMenu}&chatMode=${record.chatMode}&appId=${record.appId}`;
  81. if (record.appId) {
  82. navigate({
  83. pathname: '/knowledgeChat',
  84. search: search,
  85. })
  86. }
  87. }}
  88. >
  89. {record.title}
  90. </div>
  91. };
  92. }) : undefined,
  93. };
  94. })
  95. }}
  96. key={index}
  97. >
  98. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }}>
  99. {item.title}
  100. </div>
  101. </Dropdown>
  102. })
  103. }
  104. {/*<div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }} onClick={() => {*/}
  105. {/* navigate({*/}
  106. {/* pathname: '/deepseekChat',*/}
  107. {/* })*/}
  108. {/*}}>*/}
  109. {/* DeepSeek问答*/}
  110. {/*</div>*/}
  111. {/* 右侧区域 - 开放平台按钮 */}
  112. <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
  113. <button
  114. className='open-platform-btn'
  115. onClick={() => window.open('https://llm.jkec.info:11431', '_blank')}
  116. >
  117. 建科 • 小智开放平台
  118. </button>
  119. </div>
  120. </div>
  121. <div className='deekSeek-content'>
  122. <div className='deekSeek-content-title'>
  123. <img src={jkxz.src} />
  124. </div>
  125. <div className='deekSeek-content-title-sm' style={{ marginBottom: isMobileScreen ? 14 : 20 }}>
  126. 智能问答助手
  127. </div>
  128. <div className={isMobileScreen ? 'deekSeek-content-mobile' : 'deekSeek-content-pc'}>
  129. <Chat />
  130. </div>
  131. </div>
  132. </div>
  133. </Spin>
  134. );
  135. };
  136. export default DeekSeek;