|
|
@@ -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}
|