DeekSeekHome.tsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import * as React from 'react';
  2. import { useNavigate } from "react-router-dom";
  3. import { Dropdown, Spin,Tooltip } 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. {
  28. "children": [
  29. {
  30. "chatMode": "LOCAL",
  31. "showMenu": "false",
  32. "appId": "2935625422066814976",
  33. "title": "公司作业指导书(2023版)"
  34. },
  35. {
  36. "chatMode": "LOCAL",
  37. "showMenu": "false",
  38. "appId": "2935200536655695872",
  39. "title": "常用验收规范问答"
  40. },
  41. {
  42. "chatMode": "LOCAL",
  43. "showMenu": "false",
  44. "appId": "2942568790025965568",
  45. "title": "钢结构AI监理师"
  46. }
  47. ],
  48. "title": "专业知识"
  49. },
  50. {
  51. "children": [
  52. {
  53. "chatMode": "LOCAL",
  54. "showMenu": "false",
  55. "appId": "2919677614293913600",
  56. "title": "员工入职小百科"
  57. },
  58. {
  59. "chatMode": "LOCAL",
  60. "showMenu": "false",
  61. "appId": "2919668410128666624",
  62. "title": "数字系统答疑"
  63. },
  64. {
  65. "chatMode": "LOCAL",
  66. "showMenu": "false",
  67. "appId": "2945774476037853184",
  68. "title": "企业介绍"
  69. }
  70. ],
  71. "title": "职能管理"
  72. },
  73. {
  74. "children": [],
  75. "title": "项目级应用"
  76. }
  77. ]);
  78. const init = async () => {
  79. setListLoading(true);
  80. try {
  81. const res = await api.get('/deepseek/api/appType');
  82. setList(res.data);
  83. } catch (error) {
  84. console.error(error);
  85. } finally {
  86. setListLoading(false);
  87. }
  88. }
  89. React.useEffect(() => {
  90. chatStore.clearSessions();
  91. const userInfo = localStorage.getItem('userInfo');
  92. if (userInfo) {
  93. init();
  94. }
  95. }, []);
  96. return (
  97. <Spin spinning={listLoading}>
  98. <div className='deekSeek'>
  99. <div className='deekSeek-header' style={{ justifyContent: isMobileScreen ? 'flex-start' : 'center' }}>
  100. <div style={{ display: 'flex', alignItems: 'center', margin: '0 20px' }}>
  101. <img src={whiteLogo.src} style={{ width: 20, marginRight: 10 }} />
  102. <div style={{ whiteSpace: 'nowrap' }}>
  103. 上海建科
  104. </div>
  105. </div>
  106. {
  107. list.map((item, index) => {
  108. return <Dropdown
  109. menu={{
  110. items: item.children.map((child, i) => {
  111. return {
  112. key: 'child' + i,
  113. label: <div
  114. className='deekSeek-menuds'
  115. onClick={() => {
  116. const search = `?showMenu=${child.showMenu}&chatMode=${child.chatMode}&appId=${child.appId}`;
  117. if (child.appId) {
  118. navigate({
  119. pathname: '/knowledgeChat',
  120. search: search,
  121. })
  122. }
  123. }}
  124. >
  125. <Tooltip placement="left" title={child.title}>
  126. {child.title}
  127. </Tooltip>
  128. </div>,
  129. children: child.children ? child.children.map((record, ind) => {
  130. return {
  131. key: 'record' + ind,
  132. label: <div
  133. onClick={() => {
  134. const search = `?showMenu=${record.showMenu}&chatMode=${record.chatMode}&appId=${record.appId}`;
  135. if (record.appId) {
  136. navigate({
  137. pathname: '/knowledgeChat',
  138. search: search,
  139. })
  140. }
  141. }}
  142. >
  143. {record.title}
  144. </div>
  145. };
  146. }) : undefined,
  147. };
  148. })
  149. }}
  150. key={index}
  151. >
  152. <div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#fff', cursor: 'pointer' }}>
  153. {item.title}
  154. </div>
  155. </Dropdown>
  156. })
  157. }
  158. {/*<div style={{ whiteSpace: 'nowrap', marginRight: 20, color: '#98b4fa', cursor: 'pointer' }} onClick={() => {*/}
  159. {/* navigate({*/}
  160. {/* pathname: '/deepseekChat',*/}
  161. {/* })*/}
  162. {/*}}>*/}
  163. {/* DeepSeek问答*/}
  164. {/*</div>*/}
  165. {/* 右侧区域 - 开放平台按钮 */}
  166. <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
  167. <button
  168. className='open-platform-btn'
  169. onClick={() => {
  170. // 跳转到其他平台的逻辑,这里使用window.open举例
  171. const userInfo = localStorage.getItem('userInfo');
  172. const tokenParam = userInfo ? "?token=" + JSON.parse(userInfo).token : "";
  173. window.open('https://llm.jkec.info:11431/deepseek/questionAnswer' + tokenParam, '_blank');
  174. }}
  175. >
  176. 更多
  177. </button>
  178. </div>
  179. </div>
  180. <div className='deekSeek-content'>
  181. <div className='deekSeek-content-title'>
  182. <img src={jkxz.src} />
  183. </div>
  184. <div className='deekSeek-content-title-sm' style={{ marginBottom: isMobileScreen ? 14 : 20 }}>
  185. 智能问答助手
  186. </div>
  187. <div className={isMobileScreen ? 'deekSeek-content-mobile' : 'deekSeek-content-pc'}>
  188. <Chat />
  189. </div>
  190. </div>
  191. </div>
  192. </Spin>
  193. );
  194. };
  195. export default DeekSeek;