Skip to content

Commit 2e4db45

Browse files
committed
feat(#221): 用户消息使用markdown渲染,并且用户信息与系统消息工具栏保持一致
1 parent 0efee19 commit 2e4db45

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

src/app/core/record/chat/chat-content.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,11 @@ function MessageWrapper({ chat, children }: { chat: Chat, children: React.ReactN
7070
}
7171

7272
const index = chats.findIndex(item => item.id === chat.id)
73-
if (chat.role === 'system') {
74-
return <div className="flex w-full lg:gap-4">
75-
<div className='hidden lg:flex'>
76-
{loading && index === chats.length - 1 && chat.type === 'chat' ?
77-
<LoaderPinwheel className="animate-spin" /> :
78-
chat.type === 'clipboard' ? <ClipboardCheck /> : <BotMessageSquare />
79-
}
80-
</div>
81-
<div className='text-sm leading-6 flex-1 lg:max-w-[calc(100vw-460px)] break-words'>
82-
{children}
83-
</div>
84-
</div>
85-
} else {
86-
return <div className="flex group items-center lg:gap-4">
87-
<div className="bg-primary text-primary-foreground px-4 py-2 rounded-lg lg:max-w-[calc(100vw-600px)]">
88-
{chat.content}
89-
</div>
73+
return <div className="flex w-full lg:gap-4">
74+
{
75+
chat.role === 'user' ?
9076
<div className="relative">
91-
<Avatar className='rounded size-9 items-center justify-center hidden lg:flex'>
77+
<Avatar className='rounded size-6 items-center justify-center hidden lg:flex'>
9278
{
9379
userInfo?.avatar_url ?
9480
<AvatarImage src={userInfo?.avatar_url} /> : <UserRound />
@@ -97,9 +83,18 @@ function MessageWrapper({ chat, children }: { chat: Chat, children: React.ReactN
9783
<Button onClick={revertChat} size="icon" className="absolute top-0 right-0 hidden group-hover:flex">
9884
<Undo2 />
9985
</Button>
86+
</div> :
87+
<div className='hidden lg:flex'>
88+
{loading && index === chats.length - 1 && chat.type === 'chat' ?
89+
<LoaderPinwheel className="animate-spin" /> :
90+
chat.type === 'clipboard' ? <ClipboardCheck /> : <BotMessageSquare />
91+
}
10092
</div>
93+
}
94+
<div className='text-sm leading-6 flex-1 break-words'>
95+
{children}
10196
</div>
102-
}
97+
</div>
10398
}
10499

105100
function Message({ chat }: { chat: Chat }) {

src/app/core/record/chat/chat-preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import './chat.scss';
1818

1919
type ThemeType = 'light' | 'dark' | 'system';
2020

21-
export default function ChatPreview({text}: {text: string}) {
21+
export default function ChatPreview({text}: {text: string, themeReverse?: boolean}) {
2222
useEffect(() => {
2323
hljs.registerLanguage('javascript', javascript);
2424
hljs.registerLanguage('typescript', typescript);

src/app/core/record/chat/message-control.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ export default function MessageControl({chat, children}: {chat: Chat, children:
9494
<Separator orientation="vertical" className="h-4" />
9595
{
9696
count ? <>
97-
<Button className="hidden lg:block" variant={"ghost"} size="sm" disabled>
97+
<Button className="hidden lg:flex" variant={"ghost"} size="sm" disabled>
9898
<TypeIcon className="size-4" />
9999
{ count } {t('record.chat.messageControl.words')}
100100
</Button>
101-
<Separator orientation="vertical" className="h-4 hidden lg:block" />
101+
<Separator orientation="vertical" className="h-4 hidden lg:inline" />
102102
</> : null
103103
}
104104

0 commit comments

Comments
 (0)