mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-12 04:53:44 +08:00
优化代码风格
保持已有的状态库的使用风格,通过箭头函数来指定 handler 函数参数
This commit is contained in:
@@ -81,13 +81,8 @@ function useDragSideBar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function SideBar(props: { className?: string }) {
|
export function SideBar(props: { className?: string }) {
|
||||||
const [newSession, deleteSession, currentSessionIndex] = useChatStore(
|
const chatStore = useChatStore();
|
||||||
(state) => [
|
|
||||||
state.newSession,
|
|
||||||
state.deleteSession,
|
|
||||||
state.currentSessionIndex,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
// drag side bar
|
// drag side bar
|
||||||
const { onDragMouseDown, shouldNarrow } = useDragSideBar();
|
const { onDragMouseDown, shouldNarrow } = useDragSideBar();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -144,7 +139,7 @@ export function SideBar(props: { className?: string }) {
|
|||||||
<IconButton
|
<IconButton
|
||||||
icon={<CloseIcon />}
|
icon={<CloseIcon />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteSession(currentSessionIndex);
|
chatStore.deleteSession(chatStore.currentSessionIndex);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -165,7 +160,7 @@ export function SideBar(props: { className?: string }) {
|
|||||||
text={shouldNarrow ? undefined : Locale.Home.NewChat}
|
text={shouldNarrow ? undefined : Locale.Home.NewChat}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (config.dontShowMaskSplashScreen) {
|
if (config.dontShowMaskSplashScreen) {
|
||||||
newSession();
|
chatStore.newSession();
|
||||||
} else {
|
} else {
|
||||||
navigate(Path.NewChat);
|
navigate(Path.NewChat);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user