|
@@ -12,7 +12,8 @@ import DeleteIcon from "../icons/delete.svg";
|
|
|
import MaskIcon from "../icons/mask.svg";
|
|
import MaskIcon from "../icons/mask.svg";
|
|
|
import DragIcon from "../icons/drag.svg";
|
|
import DragIcon from "../icons/drag.svg";
|
|
|
import DiscoveryIcon from "../icons/discovery.svg";
|
|
import DiscoveryIcon from "../icons/discovery.svg";
|
|
|
-
|
|
|
|
|
|
|
+import faviconSrc from "../icons/favicon.png";
|
|
|
|
|
+import { EditOutlined } from '@ant-design/icons';
|
|
|
import Locale from "../locales";
|
|
import Locale from "../locales";
|
|
|
|
|
|
|
|
import { useAppConfig, useChatStore } from "../store";
|
|
import { useAppConfig, useChatStore } from "../store";
|
|
@@ -30,7 +31,8 @@ import {
|
|
|
import { Link, useNavigate } from "react-router-dom";
|
|
import { Link, useNavigate } from "react-router-dom";
|
|
|
import { isIOS, useMobileScreen } from "../utils";
|
|
import { isIOS, useMobileScreen } from "../utils";
|
|
|
import dynamic from "next/dynamic";
|
|
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, {
|
|
const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
|
|
|
loading: () => null,
|
|
loading: () => null,
|
|
@@ -147,6 +149,7 @@ export function SideBarContainer(props: {
|
|
|
style={{
|
|
style={{
|
|
|
// #3016 disable transition on ios mobile screen
|
|
// #3016 disable transition on ios mobile screen
|
|
|
transition: isMobileScreen && isIOSMobile ? "none" : undefined,
|
|
transition: isMobileScreen && isIOSMobile ? "none" : undefined,
|
|
|
|
|
+ background: '#FFFFFF'
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{children}
|
|
{children}
|
|
@@ -217,6 +220,57 @@ export function SideBar(props: { className?: string }) {
|
|
|
const config = useAppConfig();
|
|
const config = useAppConfig();
|
|
|
const chatStore = useChatStore();
|
|
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 (
|
|
return (
|
|
|
<SideBarContainer
|
|
<SideBarContainer
|
|
|
onDragStart={onDragStart}
|
|
onDragStart={onDragStart}
|
|
@@ -224,11 +278,10 @@ export function SideBar(props: { className?: string }) {
|
|
|
{...props}
|
|
{...props}
|
|
|
>
|
|
>
|
|
|
<SideBarHeader
|
|
<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
|
|
<IconButton
|
|
|
icon={<MaskIcon />}
|
|
icon={<MaskIcon />}
|
|
|
text={shouldNarrow ? undefined : Locale.Mask.Name}
|
|
text={shouldNarrow ? undefined : Locale.Mask.Name}
|
|
@@ -249,8 +302,18 @@ export function SideBar(props: { className?: string }) {
|
|
|
onClick={() => setShowPluginSelector(true)}
|
|
onClick={() => setShowPluginSelector(true)}
|
|
|
shadow
|
|
shadow
|
|
|
/>
|
|
/>
|
|
|
- </div>
|
|
|
|
|
- {showPluginSelector && (
|
|
|
|
|
|
|
+ </div> */}
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ style={{ marginBottom: 20 }}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ chatStore.newSession();
|
|
|
|
|
+ navigate(Path.Chat);
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 新建对话
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ {/* {showPluginSelector && (
|
|
|
<Selector
|
|
<Selector
|
|
|
items={[
|
|
items={[
|
|
|
{
|
|
{
|
|
@@ -270,9 +333,9 @@ export function SideBar(props: { className?: string }) {
|
|
|
navigate(s[0], { state: { fromHome: true } });
|
|
navigate(s[0], { state: { fromHome: true } });
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
- )}
|
|
|
|
|
|
|
+ )} */}
|
|
|
</SideBarHeader>
|
|
</SideBarHeader>
|
|
|
- <SideBarBody
|
|
|
|
|
|
|
+ {/* <SideBarBody
|
|
|
onClick={(e) => {
|
|
onClick={(e) => {
|
|
|
if (e.target === e.currentTarget) {
|
|
if (e.target === e.currentTarget) {
|
|
|
navigate(Path.Home);
|
|
navigate(Path.Home);
|
|
@@ -280,8 +343,8 @@ export function SideBar(props: { className?: string }) {
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<ChatList narrow={shouldNarrow} />
|
|
<ChatList narrow={shouldNarrow} />
|
|
|
- </SideBarBody>
|
|
|
|
|
- <SideBarTail
|
|
|
|
|
|
|
+ </SideBarBody> */}
|
|
|
|
|
+ {/* <SideBarTail
|
|
|
primaryAction={
|
|
primaryAction={
|
|
|
<>
|
|
<>
|
|
|
<div className={styles["sidebar-action"] + " " + styles.mobile}>
|
|
<div className={styles["sidebar-action"] + " " + styles.mobile}>
|
|
@@ -329,6 +392,12 @@ export function SideBar(props: { className?: string }) {
|
|
|
shadow
|
|
shadow
|
|
|
/>
|
|
/>
|
|
|
}
|
|
}
|
|
|
|
|
+ /> */}
|
|
|
|
|
+ <Menu
|
|
|
|
|
+ style={{ border: 'none' }}
|
|
|
|
|
+ // onClick={onClick}
|
|
|
|
|
+ mode="inline"
|
|
|
|
|
+ items={menuList}
|
|
|
/>
|
|
/>
|
|
|
</SideBarContainer>
|
|
</SideBarContainer>
|
|
|
);
|
|
);
|