Browse Source

修复分享及入口本地与线上模式问题

李富豪 6 months ago
parent
commit
ce42cc77a8
2 changed files with 21 additions and 15 deletions
  1. 12 10
      app/components/DeekSeekHome.tsx
  2. 9 5
      app/components/chat.tsx

+ 12 - 10
app/components/DeekSeekHome.tsx

@@ -15,6 +15,8 @@ const DeekSeek: React.FC = () => {
 
     const [list, setList] = React.useState<{ title: string, onClick?: () => void }[]>([]);
 
+    const URLSearchParams = '?showMenu=true&chatMode=LOCAL';
+
     React.useEffect(() => {
         chatStore.clearSessions();
         setList([
@@ -24,18 +26,18 @@ const DeekSeek: React.FC = () => {
                     navigate({ pathname: '/deepseekChat' })
                 }
             },
-            {
-                title: '知识库问答',
-                onClick: () => {
-                    navigate({ pathname: '/knowledgeChat' })
-                }
-            },
+            // {
+            //     title: '知识库问答',
+            //     onClick: () => {
+            //         navigate({ pathname: '/knowledgeChat' })
+            //     }
+            // },
             {
                 title: '数字化系统答疑',
                 onClick: () => {
                     navigate({
                         pathname: '/knowledgeChat',
-                        search: '?showMenu=false&appId=2919668410128666624'
+                        search: URLSearchParams + '&appId=2919668410128666624'
                     })
                 }
             },
@@ -44,16 +46,16 @@ const DeekSeek: React.FC = () => {
                 onClick: () => {
                     navigate({
                         pathname: '/knowledgeChat',
-                        search: '?showMenu=false&appId=2919677614293913600'
+                        search: URLSearchParams + '&appId=2919677614293913600'
                     })
                 }
             },
             {
-                title: '钢结构施工规范',
+                title: '钢结构智能监理',
                 onClick: () => {
                     navigate({
                         pathname: '/knowledgeChat',
-                        search: '?showMenu=false&appId=2920304945362505728'
+                        search: URLSearchParams + '&appId=2920304945362505728'
                     })
                 }
             },

+ 9 - 5
app/components/chat.tsx

@@ -1009,15 +1009,11 @@ function _Chat() {
 
   const [selectedFruit, setSelectedFruit] = React.useState(chatStore.chatMode);
 
-  // useEffect(() => {
-  // }, []);
-
   // 获取应用列表
   const fetchApplicationList = async () => {
     setLoading(true);
     try {
       let url = null;
-      console.log('selectedFruit', selectedFruit);
       if (selectedFruit === 'LOCAL') {
         url = '/deepseek/api/application/list';
       } else {
@@ -1687,7 +1683,7 @@ function _Chat() {
                 trigger="click"
                 title="分享该应用"
                 content={() => {
-                  const url = `${window.location.origin}/#/knowledgeChat?showMenu=false&appId=${appValue}`
+                  const url = `${window.location.origin}/#/knowledgeChat?showMenu=false&chatMode=${selectedFruit}&appId=${appValue}`
                   return <div>
                     <div style={{ marginBottom: 10 }}>
                       {url}
@@ -2076,10 +2072,18 @@ function _Chat() {
 
 export function Chat() {
   const chatStore = useChatStore();
+  const location = useLocation();
   const sessionIndex = chatStore.currentSessionIndex;
 
   useEffect(() => {
     chatStore.setModel('BigModel');
+    const search = location.search;
+    const params = new URLSearchParams(search);
+    const chatMode = params.get('chatMode');
+
+    if (chatMode) {
+      chatStore.setChatMode(chatMode as "ONLINE" | "LOCAL");
+    }
   }, []);
 
   return <_Chat key={sessionIndex}></_Chat>;