diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07551f4b3..aa9204b2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v2 with: - draft: false + draft: true files: | dist/*.exe dist/*.zip diff --git a/package.json b/package.json index 4d17d4d50..aa4f82f7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cherry-studio", - "version": "0.4.5", + "version": "0.4.6", "description": "A powerful AI assistant for producer.", "main": "./out/main/index.js", "author": "kangfenmao@qq.com", diff --git a/src/renderer/src/pages/home/components/Message.tsx b/src/renderer/src/pages/home/components/Message.tsx index ad33c3de8..37de10a00 100644 --- a/src/renderer/src/pages/home/components/Message.tsx +++ b/src/renderer/src/pages/home/components/Message.tsx @@ -17,8 +17,8 @@ import { Message } from '@renderer/types' import { firstLetter, removeLeadingEmoji } from '@renderer/utils' import { Avatar, Dropdown, Tooltip } from 'antd' import dayjs from 'dayjs' -import { isEmpty, upperFirst } from 'lodash' -import { FC, useCallback, useState } from 'react' +import { upperFirst } from 'lodash' +import { FC, useCallback, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' import Markdown from './markdown/Markdown' @@ -43,14 +43,14 @@ const MessageItem: FC = ({ message, index, showMenu, onDeleteMessage }) = const isUserMessage = message.role === 'user' const canRegenerate = isLastMessage && message.role === 'assistant' - const onCopy = () => { + const onCopy = useCallback(() => { navigator.clipboard.writeText(message.content) window.message.success({ content: t('message.copied'), key: 'copy-message' }) setCopied(true) setTimeout(() => setCopied(false), 2000) - } + }, [message.content, t]) - const onDelete = async () => { + const onDelete = useCallback(async () => { const confirmed = await window.modal.confirm({ icon: null, title: t('message.message.delete.title'), @@ -59,23 +59,14 @@ const MessageItem: FC = ({ message, index, showMenu, onDeleteMessage }) = okType: 'danger' }) confirmed && onDeleteMessage?.(message) - } + }, [message, onDeleteMessage, t]) - const onEdit = () => { - EventEmitter.emit(EVENT_NAMES.EDIT_MESSAGE, message) - } + const onEdit = useCallback(() => EventEmitter.emit(EVENT_NAMES.EDIT_MESSAGE, message), [message]) - const onRegenerate = () => { + const onRegenerate = useCallback(() => { onDeleteMessage?.(message) setTimeout(() => EventEmitter.emit(EVENT_NAMES.REGENERATE_MESSAGE), 100) - } - - const getMessageContent = (message: Message) => { - if (isEmpty(message.content) && message.status === 'paused') { - return t('message.chat.completion.paused') - } - return message.content - } + }, [message, onDeleteMessage]) const getUserName = useCallback(() => { if (message.id === 'assistant') { @@ -111,73 +102,95 @@ const MessageItem: FC = ({ message, index, showMenu, onDeleteMessage }) = const messageBorder = showMessageDivider ? undefined : 'none' - return ( - - - - {message.role === 'assistant' ? ( - - {firstLetter(assistant?.name).toUpperCase()} - - ) : ( - + return useMemo( + () => ( + + + + {message.role === 'assistant' ? ( + + {firstLetter(assistant?.name).toUpperCase()} + + ) : ( + + )} + + {removeLeadingEmoji(getUserName())} + {dayjs(message.createdAt).format('MM/DD HH:mm')} + + + + + {message.status === 'sending' && ( + + + + )} + {message.status !== 'sending' && } + {message.usage && !generating && ( + + Tokens: {message.usage.total_tokens} | ↑{message.usage.prompt_tokens}↓{message.usage.completion_tokens} + )} - - {removeLeadingEmoji(getUserName())} - {dayjs(message.createdAt).format('MM/DD HH:mm')} - - - - - {message.status === 'sending' && ( - - - - )} - {message.status !== 'sending' && } - {message.usage && !generating && ( - - Tokens: {message.usage.total_tokens} | ↑{message.usage.prompt_tokens}↓{message.usage.completion_tokens} - - )} - {showMenu && ( - - {message.role === 'user' && ( - - - + {showMenu && ( + + {message.role === 'user' && ( + + + + + + )} + + + {!copied && } + {copied && } - )} - - - {!copied && } - {copied && } - - - - - - - - {canRegenerate && ( - - - + + + - )} - {!isUserMessage && ( - - - - - - )} - - )} - - + {canRegenerate && ( + + + + + + )} + {!isUserMessage && ( + + + + + + )} + + )} + + + ), + [ + assistant?.name, + avatar, + canRegenerate, + copied, + fontFamily, + generating, + getDropdownMenus, + getUserName, + isLastMessage, + isUserMessage, + message, + messageBorder, + onCopy, + onDelete, + onEdit, + onRegenerate, + showMenu, + t + ] ) } diff --git a/src/renderer/src/pages/home/components/TopicsTab.tsx b/src/renderer/src/pages/home/components/TopicsTab.tsx index a413ec936..d5085896f 100644 --- a/src/renderer/src/pages/home/components/TopicsTab.tsx +++ b/src/renderer/src/pages/home/components/TopicsTab.tsx @@ -134,6 +134,7 @@ const TopicListItem = styled.div` white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + font-family: Poppins; &:hover { background-color: var(--color-background-soft); }