feat: close #380 collapse side bar

This commit is contained in:
Yidadaa
2023-04-21 02:52:53 +08:00
parent 5185166e3b
commit 82ad0573be
5 changed files with 125 additions and 35 deletions

View File

@@ -22,6 +22,7 @@ export function ChatItem(props: {
selected: boolean;
id: number;
index: number;
narrow?: boolean;
}) {
return (
<Draggable draggableId={`${props.id}`} index={props.index}>
@@ -35,13 +36,20 @@ export function ChatItem(props: {
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<div className={styles["chat-item-title"]}>{props.title}</div>
<div className={styles["chat-item-info"]}>
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
</div>
{props.narrow ? (
<div className={styles["chat-item-narrow"]}>{props.count}</div>
) : (
<>
<div className={styles["chat-item-title"]}>{props.title}</div>
<div className={styles["chat-item-info"]}>
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
</div>
</>
)}
<div className={styles["chat-item-delete"]} onClick={props.onDelete}>
<DeleteIcon />
</div>
@@ -51,7 +59,7 @@ export function ChatItem(props: {
);
}
export function ChatList() {
export function ChatList(props: { narrow?: boolean }) {
const [sessions, selectedIndex, selectSession, removeSession, moveSession] =
useChatStore((state) => [
state.sessions,
@@ -101,7 +109,12 @@ export function ChatList() {
navigate(Path.Chat);
selectSession(i);
}}
onDelete={() => chatStore.deleteSession(i)}
onDelete={() => {
if (!props.narrow || confirm(Locale.Home.DeleteChat)) {
chatStore.deleteSession(i);
}
}}
narrow={props.narrow}
/>
))}
{provided.placeholder}