李富豪 1 год назад
Родитель
Сommit
6977de78ef

+ 33 - 34
app/components/chat.tsx

@@ -16,6 +16,7 @@ import ExportIcon from "../icons/share.svg";
 import ReturnIcon from "../icons/return.svg";
 import CopyIcon from "../icons/copy.svg";
 import faviconSrc from "../icons/favicon.png";
+import LeftIcon from "../icons/left.svg";
 import Favicon from "../icons/favicon.svg";
 import LoadingIcon from "../icons/three-dots.svg";
 import LoadingButtonIcon from "../icons/loading.svg";
@@ -1452,40 +1453,38 @@ function _Chat() {
         <div style={{ display: 'flex', alignItems: 'center' }}
           className={`window-header-title ${styles["chat-body-title"]}`}>
           <div>
-            <img style={{ marginTop: '10%', marginRight: '10px', height: 42 }} src={faviconSrc.src} />
-            {/* <Favicon className="window-header-icon" /> */}
+            {
+              isMobileScreen &&
+              <IconButton
+                style={{ padding: 0, marginRight: 20 }}
+                icon={<LeftIcon />}
+                text={Locale.NewChat.Return}
+                onClick={() => navigate(Path.Home)}
+              />
+            }
           </div>
           <div>
-            <div
-              className={`window-header-main-title ${styles["chat-body-main-title"]}`}
-            // onClickCapture={() => setIsEditingMessage(true)}
-            >
-              建科·小智
-            </div>
-            <div className="window-header-sub-title">
-              {Locale.Chat.SubTitle(session.messages.length)}
-            </div>
+            {
+              appList.length > 1 ?
+                <Select
+                  style={{ width: '100%', height: 38, marginRight: 5 }}
+                  placeholder='请选择'
+                  options={appList}
+                  value={appValue}
+                  onChange={(value) => {
+                    // setAppValue(value);
+                    // localStorage.clear();
+                    // localStorage.setItem('appId', value as string);
+                    // location.reload()
+                  }}
+                />
+                :
+                null
+            }
           </div>
         </div>
         <div className="window-actions">
-          {
-            appList.length > 1 ?
-              <Select
-                style={{ width: '100%', height: 38, marginRight: 5 }}
-                placeholder='请选择'
-                options={appList}
-                value={appValue}
-                onChange={(value) => {
-                  setAppValue(value);
-                  localStorage.clear();
-                  localStorage.setItem('appId', value as string);
-                  location.reload()
-                }}
-              />
-              :
-              null
-          }
-          <IconButton
+          {/* <IconButton
             icon={<AddIcon />}
             bordered
             title='新建对话'
@@ -1494,7 +1493,7 @@ function _Chat() {
               localStorage.clear()
               location.reload()
             }}
-          />
+          /> */}
           {/* {!isMobileScreen && (
             <div className="window-action-button">
               <IconButton
@@ -1506,16 +1505,17 @@ function _Chat() {
               />
             </div>
           )} */}
-          {/* <div className="window-action-button">
+          <div className="window-action-button">
             <IconButton
               icon={<ExportIcon />}
               bordered
               title={Locale.Chat.Actions.Export}
               onClick={() => {
-                setShowExport(true);
+                // setShowExport(true);
+                console.log('分享聊天记录');
               }}
             />
-          </div> */}
+          </div>
           {/* {showMaxIcon && (
             <div className="window-action-button">
               <IconButton
@@ -1532,7 +1532,6 @@ function _Chat() {
             </div>
           )} */}
         </div>
-
         {/* <PromptToast
           showToast={!hitBottom}
           showModal={showPromptModal}

+ 1 - 1
app/components/home.module.scss

@@ -135,7 +135,7 @@
 
 .sidebar-header {
   position: relative;
-  padding-top: 20px;
+  // padding-top: 20px;
   padding-bottom: 20px;
   display: flex;
   justify-content: space-between;

+ 2 - 2
app/components/home.tsx

@@ -267,9 +267,9 @@ function Screen() {
           <Routes>
             <Route path={Path.Home} element={<Chat />} />
             {/* <Route path={'/record'} element={<Record />} /> */}
-            {/* <Route path={Path.NewChat} element={<NewChat />} /> */}
+            <Route path={Path.NewChat} element={<NewChat />} />
             {/* <Route path={Path.Masks} element={<MaskPage />} /> */}
-            {/* <Route path={Path.Chat} element={<Chat />} /> */}
+            <Route path={Path.Chat} element={<Chat />} />
             {/* <Route path={Path.Settings} element={<Settings />} /> */}
           </Routes>
         </WindowContent>

+ 81 - 12
app/components/sidebar.tsx

@@ -12,7 +12,8 @@ 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 } from "../store";
@@ -30,7 +31,8 @@ import {
 import { Link, useNavigate } from "react-router-dom";
 import { isIOS, useMobileScreen } from "../utils";
 import dynamic from "next/dynamic";
-import { showConfirm, Selector } from "./ui-lib";
+import api from "@/app/api/api";
+import { Button, Dropdown, Menu } from "antd";
 
 const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
   loading: () => null,
@@ -147,6 +149,7 @@ export function SideBarContainer(props: {
       style={{
         // #3016 disable transition on ios mobile screen
         transition: isMobileScreen && isIOSMobile ? "none" : undefined,
+        background: '#FFFFFF'
       }}
     >
       {children}
@@ -217,6 +220,57 @@ export function SideBar(props: { className?: string }) {
   const config = useAppConfig();
   const chatStore = useChatStore();
 
+  const [menuList, setMenuList] = useState([])
+
+  // 获取聊天列表
+  const fetchChatList = async () => {
+    try {
+      const res = await api.get('/bigmodel/api/dialog/list');
+      const list = res.data.map((item: any) => {
+        return {
+          ...item,
+          children: item.children.map((child: any) => {
+            const items = [
+              {
+                key: '1',
+                label: '重命名',
+              },
+              {
+                key: '2',
+                label: '导出',
+              },
+              {
+                key: '3',
+                label: '删除',
+              },
+            ];
+
+            return {
+              ...child,
+              label: <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
+                <div style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', marginRight: 10 }}>
+                  {child.label}
+                </div>
+                <div style={{ width: 20 }}>
+                  <Dropdown menu={{ items }} trigger={['click']} placement="bottomRight">
+                    <EditOutlined />
+                  </Dropdown>
+                </div>
+              </div>
+            }
+          })
+        }
+      })
+      setMenuList(list);
+    } catch (error) {
+      console.error(error)
+    }
+  }
+
+  useEffect(() => {
+    fetchChatList();
+  }, []);
+
   return (
     <SideBarContainer
       onDragStart={onDragStart}
@@ -224,11 +278,10 @@ export function SideBar(props: { className?: string }) {
       {...props}
     >
       <SideBarHeader
-        title="NextChat"
-        subTitle="Build your own AI assistant."
-        logo={<ChatGptIcon />}
+        title="问答历史"
+        logo={<img style={{ marginTop: '10%', marginRight: '10px', height: 42 }} src={faviconSrc.src} />}
       >
-        <div className={styles["sidebar-header-bar"]}>
+        {/* <div className={styles["sidebar-header-bar"]}>
           <IconButton
             icon={<MaskIcon />}
             text={shouldNarrow ? undefined : Locale.Mask.Name}
@@ -249,8 +302,18 @@ export function SideBar(props: { className?: string }) {
             onClick={() => setShowPluginSelector(true)}
             shadow
           />
-        </div>
-        {showPluginSelector && (
+        </div> */}
+        <Button
+          type="primary"
+          style={{ marginBottom: 20 }}
+          onClick={() => {
+            chatStore.newSession();
+            navigate(Path.Chat);
+          }}
+        >
+          新建对话
+        </Button>
+        {/* {showPluginSelector && (
           <Selector
             items={[
               {
@@ -270,9 +333,9 @@ export function SideBar(props: { className?: string }) {
               navigate(s[0], { state: { fromHome: true } });
             }}
           />
-        )}
+        )} */}
       </SideBarHeader>
-      <SideBarBody
+      {/* <SideBarBody
         onClick={(e) => {
           if (e.target === e.currentTarget) {
             navigate(Path.Home);
@@ -280,8 +343,8 @@ export function SideBar(props: { className?: string }) {
         }}
       >
         <ChatList narrow={shouldNarrow} />
-      </SideBarBody>
-      <SideBarTail
+      </SideBarBody> */}
+      {/* <SideBarTail
         primaryAction={
           <>
             <div className={styles["sidebar-action"] + " " + styles.mobile}>
@@ -329,6 +392,12 @@ export function SideBar(props: { className?: string }) {
             shadow
           />
         }
+      /> */}
+      <Menu
+        style={{ border: 'none' }}
+        // onClick={onClick}
+        mode="inline"
+        items={menuList}
       />
     </SideBarContainer>
   );

+ 3 - 3
app/constant.ts

@@ -91,8 +91,8 @@ export enum StoreKey {
 
 export const DEFAULT_SIDEBAR_WIDTH = 300;
 export const MAX_SIDEBAR_WIDTH = 500;
-export const MIN_SIDEBAR_WIDTH = 230;
-export const NARROW_SIDEBAR_WIDTH = 100;
+export const MIN_SIDEBAR_WIDTH = 200;
+export const NARROW_SIDEBAR_WIDTH = 200;
 
 export const ACCESS_CODE_PREFIX = "nk-";
 
@@ -229,7 +229,7 @@ export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lan
 // Latex inline: $x^2$
 // Latex block: $$e=mc^2$$
 // `;
-export const DEFAULT_SYSTEM_TEMPLATE :any = null;
+export const DEFAULT_SYSTEM_TEMPLATE: any = null;
 // `
 // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
 // Knowledge cutoff: {{cutoff}}

+ 1 - 1
app/styles/window.scss

@@ -1,5 +1,5 @@
 .window-header {
-  padding: 14px 20px;
+  padding: 14px;
   position: relative;
   display: flex;
   justify-content: space-between;

+ 1 - 1
next.config.mjs

@@ -92,7 +92,7 @@ if (mode !== "export") {
       },
       {
         source: "/bigmodel-api/:path*",
-        destination: "http://118.195.177.247:8091/:path*",
+        destination: "http://xia0miduo.gicp.net:8091/:path*",
       },
     ];