DeekSeekHome.tsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. {/* 右侧跳转按钮 */}
  121. <div style={{
  122. marginLeft: 'auto', // 自动占据左侧空间,将按钮推到最右侧
  123. marginRight: 20 // 右侧间距,与其他元素保持一致
  124. }}>
  125. <button
  126. onClick={() => {
  127. // 跳转到其他平台的逻辑,这里使用window.open举例
  128. const userInfo = localStorage.getItem('userInfo');
  129. const tokenParam = userInfo ? "?token=" + JSON.parse(userInfo).token : "";
  130. window.open('http://localhost:3100' + tokenParam, '_blank');
  131. // 如果是内部路由跳转,可以使用navigate:
  132. // navigate('/target-path');
  133. }}
  134. style={{
  135. padding: '6px 12px',
  136. backgroundColor: '#165DFF', // 蓝色按钮,可根据设计调整
  137. color: 'white',
  138. border: 'none',
  139. borderRadius: 4,
  140. cursor: 'pointer',
  141. whiteSpace: 'nowrap'
  142. }}
  143. >
  144. 前往开放平台
  145. </button>
  146. </div>
  147. </div>
  148. <div className='deekSeek-content'>
  149. <div className='deekSeek-content-title'>
  150. <img src={jkxz.src} />
  151. </div>
  152. <div className='deekSeek-content-title-sm' style={{ marginBottom: isMobileScreen ? 14 : 20 }}>
  153. 智能问答助手
  154. </div>
  155. <div className={isMobileScreen ? 'deekSeek-content-mobile' : 'deekSeek-content-pc'}>
  156. <Chat />
  157. </div>
  158. </div>
  159. </div>
  160. </Spin>
  161. );
  162. };
  163. export default DeekSeek;