李富豪 9 місяців тому
батько
коміт
9605598995

+ 2 - 1
app/components/DeekSeek.tsx

@@ -17,11 +17,12 @@ const DeekSeek: React.FC = () => {
 
     React.useEffect(() => {
         chatStore.clearSessions();
+        chatStore.setModel('DeepSeek');
         setList([
             {
                 title: '知识库问答',
                 onClick: () => {
-                    navigate({ pathname: '/chat' })
+                    navigate({ pathname: '/knowledgeChat' })
                 }
             },
             {

+ 0 - 4
app/components/chat.module.scss

@@ -618,10 +618,6 @@
   outline: none;
   box-sizing: border-box;
   min-height: 68px;
-  // 背景
-  background: rgba(255, 255, 255, 0.1);
-  // 背景模糊程度
-  backdrop-filter: blur(10px);
   // 文字颜色
   color: #FFFFFF;
 }

+ 11 - 6
app/components/chat.tsx

@@ -8,7 +8,7 @@ import React, {
   Fragment,
   RefObject,
 } from "react";
-import { CommentOutlined } from '@ant-design/icons';
+import { HomeOutlined } from '@ant-design/icons';
 import SendWhiteIcon from "../icons/send-white.svg";
 import BrainIcon from "../icons/brain.svg";
 import RenameIcon from "../icons/rename.svg";
@@ -1563,7 +1563,7 @@ function _Chat() {
                 style={{ padding: 0, marginRight: 20 }}
                 icon={<LeftIcon />}
                 text={Locale.NewChat.Return}
-                onClick={() => navigate(Path.Home)}
+                onClick={() => navigate('/knowledgeChat')}
               />
             }
           </div>
@@ -1612,11 +1612,11 @@ function _Chat() {
             </div>
           )} */}
           <IconButton
-            icon={<CommentOutlined />}
+            icon={<HomeOutlined />}
             bordered
-            title={Locale.Chat.Actions.Export}
+            title="首页"
             onClick={() => {
-              navigate({ pathname: '/' })
+              navigate({ pathname: '/' });
             }}
           />
           <div className="window-action-button">
@@ -1624,7 +1624,7 @@ function _Chat() {
               trigger="click"
               title="分享"
               content={() => {
-                const url = `${window.location.origin}/#/chat?appId=${appValue}`
+                const url = `${window.location.origin}/#/knowledgeChat?appId=${appValue}`
                 return <div>
                   <div style={{ marginBottom: 10 }}>
                     {url}
@@ -2039,5 +2039,10 @@ function _Chat() {
 export function Chat() {
   const chatStore = useChatStore();
   const sessionIndex = chatStore.currentSessionIndex;
+
+  useEffect(() => {
+    chatStore.setModel('BigModel');
+  }, []);
+
   return <_Chat key={sessionIndex}></_Chat>;
 }

+ 21 - 55
app/components/home.tsx

@@ -1,34 +1,27 @@
 "use client";
 
 require("../polyfill");
-
-import { useState, useEffect, FC } from "react";
-
+import { useState, useEffect } from "react";
+import {
+  HashRouter as Router,
+  Routes,
+  Route,
+  useLocation,
+} from "react-router-dom";
 import styles from "./home.module.scss";
-
 import BotIcon from "../icons/bot.svg";
 import loadingIcon from "../icons/loading.gif";
-
 import { getCSSVar, useMobileScreen } from "../utils";
-
 import dynamic from "next/dynamic";
 import { Path, SlotID } from "../constant";
 import { ErrorBoundary } from "./error";
-
 import { getISOLang, getLang } from "../locales";
-
-import {
-  HashRouter as Router,
-  Routes,
-  Route,
-  useLocation,
-} from "react-router-dom";
 import { SideBar } from "./sidebar";
 import { useAppConfig } from "../store/config";
 import { AuthPage } from "./auth";
 import { getClientConfig } from "../config/client";
 import { type ClientApi, getClientApi } from "../client/api";
-import { useAccessStore, useChatStore } from "../store";
+import { useAccessStore } from "../store";
 
 export function Loading() {
   /** second版本注释掉进度条 */
@@ -127,7 +120,7 @@ const Record = dynamic(
   }
 );
 
-const DeekSeek = dynamic(
+const HomeApp = dynamic(
   async () => {
     return (await import("./DeekSeek"))
   },
@@ -245,7 +238,6 @@ function Screen() {
   const config = useAppConfig();
   const location = useLocation();
   const isArtifact = location.pathname.includes(Path.Artifacts);
-  const isHome = location.pathname === Path.Home;
   const isAuth = location.pathname === Path.Auth;
   const isSd = location.pathname === Path.Sd;
   const isSdNew = location.pathname === Path.SdNew;
@@ -266,51 +258,25 @@ function Screen() {
     );
   }
 
-  const DeepSeekApp: FC = () => {
-    const chatStore = useChatStore();
-
-    useEffect(() => {
-      chatStore.setModel('DeepSeek');
-    }, [])
-
-    return (
-      <>
-        <WindowContent>
-          <Routes>
-            <Route path='/' element={<DeekSeek />} />
-          </Routes>
-        </WindowContent>
-      </>
-    )
-  }
-
-  const BigModelApp: FC = () => {
-    const chatStore = useChatStore();
-
-    useEffect(() => {
-      chatStore.setModel('BigModel');
-    }, [])
+  const renderContent = () => {
+    if (isAuth) return <AuthPage />;
+    if (isSd) return <Sd />;
+    if (isSdNew) return <Sd />;
 
     return (
       <>
-        <SideBar className={isHome ? styles["sidebar-show"] : ""} />
+        {
+          location.pathname !== '/' &&
+          <SideBar className={location.pathname === '/knowledgeChat' ? styles["sidebar-show"] : ""} />
+        }
         <WindowContent>
           <Routes>
-            <Route path='/chat' element={<Chat />} />
+            <Route path='/' element={<HomeApp />} />
+            <Route path='/knowledgeChat' element={<Chat />} />
+            <Route path='/newChat' element={<Chat />} />
           </Routes>
         </WindowContent>
       </>
-    )
-  }
-
-  const renderContent = () => {
-    if (isAuth) return <AuthPage />;
-    if (isSd) return <Sd />;
-    if (isSdNew) return <Sd />;
-    return (
-      <>
-        {location.pathname === '/chat' ? <BigModelApp /> : <DeepSeekApp />}
-      </>
     );
   };
 
@@ -359,4 +325,4 @@ export function Home() {
       </Router>
     </ErrorBoundary>
   );
-}
+}

+ 3 - 127
app/components/sidebar.tsx

@@ -1,46 +1,23 @@
 import React, { useEffect, useRef, useMemo, useState, Fragment } from "react";
-
 import styles from "./home.module.scss";
-
-import { IconButton } from "./button";
-import SettingsIcon from "../icons/settings.svg";
-import GithubIcon from "../icons/github.svg";
-import ChatGptIcon from "../icons/chatgpt.svg";
-import AddIcon from "../icons/add.svg";
-import CloseIcon from "../icons/close.svg";
-import DeleteIcon from "../icons/delete.svg";
-import MaskIcon from "../icons/mask.svg";
 import DragIcon from "../icons/drag.svg";
-import DiscoveryIcon from "../icons/discovery.svg";
 import faviconSrc from "../icons/favicon.png";
 import { EditOutlined } from '@ant-design/icons';
-import Locale from "../locales";
-
 import { useAppConfig, useChatStore, useGlobalStore } from "../store";
-
 import {
   DEFAULT_SIDEBAR_WIDTH,
   MAX_SIDEBAR_WIDTH,
   MIN_SIDEBAR_WIDTH,
   NARROW_SIDEBAR_WIDTH,
-  Path,
-  PLUGINS,
-  REPO_URL,
 } from "../constant";
-
-import { Link, useNavigate } from "react-router-dom";
+import { useNavigate } from "react-router-dom";
 import { isIOS, useMobileScreen } from "../utils";
-import dynamic from "next/dynamic";
 import api from "@/app/api/api";
 import { Button, Dropdown, Form, Input, Menu, Modal } from "antd";
 import { downloadFile } from "../utils/index";
 
 const FormItem = Form.Item;
 
-const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
-  loading: () => null,
-});
-
 export function useHotKey() {
   const chatStore = useChatStore();
 
@@ -328,28 +305,6 @@ export const SideBar = (props: { className?: string }) => {
         title="问答历史"
         logo={<img style={{ height: 40 }} src={faviconSrc.src} />}
       >
-        {/* <div className={styles["sidebar-header-bar"]}>
-          <IconButton
-            icon={<MaskIcon />}
-            text={shouldNarrow ? undefined : Locale.Mask.Name}
-            className={styles["sidebar-bar-button"]}
-            onClick={() => {
-              if (config.dontShowMaskSplashScreen !== true) {
-                navigate(Path.NewChat, { state: { fromHome: true } });
-              } else {
-                navigate(Path.Masks, { state: { fromHome: true } });
-              }
-            }}
-            shadow
-          />
-          <IconButton
-            icon={<DiscoveryIcon />}
-            text={shouldNarrow ? undefined : Locale.Discovery.Name}
-            className={styles["sidebar-bar-button"]}
-            onClick={() => setShowPluginSelector(true)}
-            shadow
-          />
-        </div> */}
         <Button
           type="primary"
           style={{ marginBottom: 10 }}
@@ -358,92 +313,13 @@ export const SideBar = (props: { className?: string }) => {
             chatStore.updateCurrentSession((value) => {
               value.appId = globalStore.selectedAppId;
             });
-            navigate(Path.Chat);
+            navigate({ pathname: '/newChat' });
             await fetchChatList()
           }}
         >
           新建对话
         </Button>
-        {/* {showPluginSelector && (
-          <Selector
-            items={[
-              {
-                title: "👇 Please select the plugin you need to use",
-                value: "-",
-                disable: true,
-              },
-              ...PLUGINS.map((item) => {
-                return {
-                  title: item.name,
-                  value: item.path,
-                };
-              }),
-            ]}
-            onClose={() => setShowPluginSelector(false)}
-            onSelection={(s) => {
-              navigate(s[0], { state: { fromHome: true } });
-            }}
-          />
-        )} */}
       </SideBarHeader>
-      {/* <SideBarBody
-        onClick={(e) => {
-          if (e.target === e.currentTarget) {
-            navigate(Path.Home);
-          }
-        }}
-      >
-        <ChatList narrow={shouldNarrow} />
-      </SideBarBody> */}
-      {/* <SideBarTail
-        primaryAction={
-          <>
-            <div className={styles["sidebar-action"] + " " + styles.mobile}>
-              <IconButton
-                icon={<DeleteIcon />}
-                onClick={async () => {
-                  if (await showConfirm(Locale.Home.DeleteChat)) {
-                    chatStore.deleteSession(chatStore.currentSessionIndex);
-                  }
-                }}
-              />
-            </div>
-            <div className={styles["sidebar-action"]}>
-              <Link to={Path.Settings}>
-                <IconButton
-                  aria={Locale.Settings.Title}
-                  icon={<SettingsIcon />}
-                  shadow
-                />
-              </Link>
-            </div>
-            <div className={styles["sidebar-action"]}>
-              <a href={REPO_URL} target="_blank" rel="noopener noreferrer">
-                <IconButton
-                  aria={Locale.Export.MessageFromChatGPT}
-                  icon={<GithubIcon />}
-                  shadow
-                />
-              </a>
-            </div>
-          </>
-        }
-        secondaryAction={
-          <IconButton
-            icon={<AddIcon />}
-            text={shouldNarrow ? undefined : Locale.Home.NewChat}
-            onClick={() => {
-              if (config.dontShowMaskSplashScreen) {
-                chatStore.newSession();
-                navigate(Path.Chat);
-              } else {
-                navigate(Path.NewChat);
-              }
-            }}
-            shadow
-          />
-        }
-      /> */}
       <Menu
         style={{ border: 'none' }}
         onClick={async ({ key }) => {
@@ -470,7 +346,7 @@ export const SideBar = (props: { className?: string }) => {
             value.id = session.id;
             value.messages = list;
           });
-          navigate('/chat', { state: { fromHome: true } });
+          navigate({ pathname: '/newChat' }, { state: { fromHome: true } });
         }}
         mode="inline"
         items={menuList}