forked from XiaoMo/ChatGPT-Next-Web
feat: edit session title button
This commit is contained in:
parent
fb14785cad
commit
47a2911ee2
@ -3,6 +3,7 @@ import { memo, useState, useRef, useEffect, useLayoutEffect } from "react";
|
|||||||
|
|
||||||
import SendWhiteIcon from "../icons/send-white.svg";
|
import SendWhiteIcon from "../icons/send-white.svg";
|
||||||
import BrainIcon from "../icons/brain.svg";
|
import BrainIcon from "../icons/brain.svg";
|
||||||
|
import RenameIcon from "../icons/rename.svg";
|
||||||
import ExportIcon from "../icons/share.svg";
|
import ExportIcon from "../icons/share.svg";
|
||||||
import ReturnIcon from "../icons/return.svg";
|
import ReturnIcon from "../icons/return.svg";
|
||||||
import CopyIcon from "../icons/copy.svg";
|
import CopyIcon from "../icons/copy.svg";
|
||||||
@ -589,6 +590,13 @@ export function Chat(props: {
|
|||||||
|
|
||||||
const [showPromptModal, setShowPromptModal] = useState(false);
|
const [showPromptModal, setShowPromptModal] = useState(false);
|
||||||
|
|
||||||
|
const renameSession = () => {
|
||||||
|
const newTopic = prompt(Locale.Chat.Rename, session.topic);
|
||||||
|
if (newTopic && newTopic !== session.topic) {
|
||||||
|
chatStore.updateCurrentSession((session) => (session.topic = newTopic!));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Auto focus
|
// Auto focus
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.sideBarShowing && isMobileScreen()) return;
|
if (props.sideBarShowing && isMobileScreen()) return;
|
||||||
@ -602,14 +610,7 @@ export function Chat(props: {
|
|||||||
<div className={styles["window-header-title"]}>
|
<div className={styles["window-header-title"]}>
|
||||||
<div
|
<div
|
||||||
className={`${styles["window-header-main-title"]} ${styles["chat-body-title"]}`}
|
className={`${styles["window-header-main-title"]} ${styles["chat-body-title"]}`}
|
||||||
onClickCapture={() => {
|
onClickCapture={renameSession}
|
||||||
const newTopic = prompt(Locale.Chat.Rename, session.topic);
|
|
||||||
if (newTopic && newTopic !== session.topic) {
|
|
||||||
chatStore.updateCurrentSession(
|
|
||||||
(session) => (session.topic = newTopic!),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{session.topic}
|
{session.topic}
|
||||||
</div>
|
</div>
|
||||||
@ -628,12 +629,9 @@ export function Chat(props: {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles["window-action-button"]}>
|
<div className={styles["window-action-button"]}>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<BrainIcon />}
|
icon={<RenameIcon />}
|
||||||
bordered
|
bordered
|
||||||
title={Locale.Chat.Actions.CompressedHistory}
|
onClick={renameSession}
|
||||||
onClick={() => {
|
|
||||||
setShowPromptModal(true);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["window-action-button"]}>
|
<div className={styles["window-action-button"]}>
|
||||||
|
1
app/icons/rename.svg
Normal file
1
app/icons/rename.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16" fill="none"><defs><rect id="path_0" x="0" y="0" width="16" height="16" /></defs><g opacity="1" transform="translate(0 0) rotate(0 8 8)"><mask id="bg-mask-0" fill="white"><use xlink:href="#path_0"></use></mask><g mask="url(#bg-mask-0)" ><path id="路径 1" style="stroke:#333333; stroke-width:1.3333333333333333; stroke-opacity:1; stroke-dasharray:0 0" transform="translate(1.774903333333333 1.3006199999999999) rotate(0 6.599664999999999 6.599656666666666)" d="M2.83,13.2L13.2,2.83L10.37,0L0,10.37L0,13.2L2.83,13.2Z " /><path id="路径 2" style="stroke:#333333; stroke-width:1.3333333333333333; stroke-opacity:1; stroke-dasharray:0 0" transform="translate(9.317366666666667 4.129066666666667) rotate(0 1.4142166666666658 1.4142166666666665)" d="M0,0L2.83,2.83 " /></g></g></svg>
|
After Width: | Height: | Size: 911 B |
Loading…
Reference in New Issue
Block a user