Skip to content

Commit

Permalink
fix(chat): fix alignment for chat's button
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalYoung committed Jan 23, 2025
1 parent f28dbcb commit 91e5cd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/chat/button/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ $primaryGradientHover: #08C4FF 0%, #4892FF 50%, #8A61FF 100%;
.ant-btn.dtc__aigc__button {
border: none;
border-radius: 4px;
font-size: 12px;
display: inline-flex;
align-items: center;
&.ant-btn-sm {
border-radius: 2px;
}
Expand Down
26 changes: 17 additions & 9 deletions src/chat/demos/message.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import React, { useMemo, useState } from 'react';
import { Button, Space } from 'antd';
import { Chat } from 'dt-react-component';
import { MessageStatus } from 'dt-react-component/chat/entity';
import { Message, MessageStatus, Prompt } from 'dt-react-component/chat/entity';

class BasicPrompt extends Prompt {}
class BasicMessage extends Message {}

export default function () {
const [status, setStatus] = useState<MessageStatus>(MessageStatus.DONE);

const data = useMemo(() => {
return [
{
id: new Date().valueOf().toString(),
content: status === MessageStatus.DONE ? '输出完成' : '正在打字中...',
status,
} as any,
];
return new BasicPrompt({
id: `prompt_${new Date().valueOf().toString()}`,
title: '这是一个标题',
messages: [
new BasicMessage({
id: 'message_${new Date().valueOf().toString()}',
content: status === MessageStatus.DONE ? '输出完成' : '正在打字中...',
status,
}),
],
});
}, [status]);

return (
Expand All @@ -30,7 +37,8 @@ export default function () {
</Button>
</Space>
<Chat.Message
data={data}
prompt={data}
data={data.messages}
regenerate
onStop={() => setStatus(MessageStatus.STOPPED)}
onRegenerate={() => console.log('regenerate')}
Expand Down
2 changes: 1 addition & 1 deletion src/chat/message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function Message({
const copyInfo = useMemo<{ disabled: boolean; options: CopyOptions }>(() => {
if (typeof copy === 'boolean') {
return {
disabled: copy,
disabled: !copy,
options: {},
};
}
Expand Down

0 comments on commit 91e5cd6

Please sign in to comment.