diff --git a/src/App.tsx b/src/App.tsx index 5a1146d5..ade85eaf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -73,18 +73,18 @@ function Main() { const sortedSessions = sortSessions(store.chatSessions) function handleDragEnd(event: DragEndEvent) { - const {active, over} = event; + const { active, over } = event; if (!over) { return } if (active.id !== over.id) { - const oldIndex = sortedSessions.findIndex(({id}) => id === active.id); - const newIndex = sortedSessions.findIndex(({id}) => id === over.id); + const oldIndex = sortedSessions.findIndex(({ id }) => id === active.id); + const newIndex = sortedSessions.findIndex(({ id }) => id === over.id); const newReversed = arrayMove(sortedSessions, oldIndex, newIndex); store.setSessions(sortSessions(newReversed)) } } - + // 是否展示设置窗口 const [openSettingWindow, setOpenSettingWindow] = React.useState(false); @@ -210,14 +210,14 @@ function Main() { } ) } - const saveSession = async (session:Session) => { + const saveSession = async (session: Session) => { const filePath = await save({ filters: [{ - name: 'Export', - extensions: ['md'] + name: 'Export', + extensions: ['md'] }] - }); - if(filePath){ + }); + if (filePath) { const content = session.messages .map(msg => `**${msg.role}**:\n${msg.content}`) .join('\n\n--------------------\n\n') @@ -320,19 +320,23 @@ function Main() { }} spacing={2} > - - - - Chatbox - - + + + + + Chatbox + + + - { - sortedSessions.map((session, ix) => ( - - { - store.switchCurrentSession(session) - document.getElementById('message-input')?.focus() // better way? - }} - deleteMe={() => store.deleteChatSession(session)} - copyMe={() => { - const newSession = createSession(session.name + ' copied') - newSession.messages = session.messages - store.createChatSession(newSession, ix) - }} - switchStarred={() => { - store.updateChatSession({ - ...session, - starred: !session.starred - }) - }} - editMe={() => setConfigureChatConfig(session)} - /> - - )) - } + { + sortedSessions.map((session, ix) => ( + + { + store.switchCurrentSession(session) + document.getElementById('message-input')?.focus() // better way? + }} + deleteMe={() => store.deleteChatSession(session)} + copyMe={() => { + const newSession = createSession(session.name + ' copied') + newSession.messages = session.messages + store.createChatSession(newSession, ix) + }} + switchStarred={() => { + store.updateChatSession({ + ...session, + starred: !session.starred + }) + }} + editMe={() => setConfigureChatConfig(session)} + /> + + )) + } @@ -426,7 +430,7 @@ function Main() { + sx={{ paddingRight: '8px' }} > {t('About')} ({store.version})