-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(chat): redesign
ChatItem
ChatList
props, add time sup…
…port
- Loading branch information
1 parent
ecf69a3
commit 6a230e2
Showing
12 changed files
with
252 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { MetaData } from '@/types/meta'; | ||
|
||
export const avatar: MetaData = { | ||
avatar: '😎', | ||
title: 'Advertiser', | ||
backgroundColor: '#E8DA5A', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
import { ChatMessage } from '@/Chat'; | ||
import { ChatMessage } from '@/types/chatMessage'; | ||
|
||
export const data: ChatMessage[] = [ | ||
{ | ||
id: '1', | ||
meta: { | ||
avatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', | ||
title: 'CanisMinor', | ||
}, | ||
role: 'user', | ||
content: 'dayjs 如何使用 fromNow', | ||
createAt: 1686437950084, | ||
updateAt: 1686437950084, | ||
}, | ||
{ | ||
id: '2', | ||
meta: { | ||
avatar: '😎', | ||
title: 'Advertiser', | ||
backgroundColor: '#E8DA5A', | ||
}, | ||
role: 'assistant', | ||
content: | ||
'要使用 dayjs 的 fromNow 函数,需要先安装 dayjs 库并在代码中引入它。然后,可以使用以下语法来获取当前时间与给定时间之间的相对时间:\n\n```javascript\ndayjs().fromNow(); // 获取当前时间的相对时间\ndayjs(\'2021-05-01\').fromNow(); // 获取给定时间的相对时间\n```\n\n第一个示例将返回类似于 "几秒前"、"一分钟前"、"2 天前" 的相对时间字符串,表示当前时间与调用 fromNow 方法时的时间差。第二个示例将返回给定时间与当前时间的相对时间字符串。', | ||
createAt: 1686538950084, | ||
updateAt: 1686538950084, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { LLMRoleType } from './llm'; | ||
import { BaseDataModel } from './meta'; | ||
|
||
/** | ||
* 聊天消息错误对象 | ||
*/ | ||
export interface ChatMessageError { | ||
/** | ||
* 错误信息 | ||
*/ | ||
message: string; | ||
status: number; | ||
type: 'general' | 'llm'; | ||
} | ||
|
||
export interface ChatMessage extends BaseDataModel { | ||
/** | ||
* @title 内容 | ||
* @description 消息内容 | ||
*/ | ||
content: string; | ||
|
||
// 扩展字段 | ||
extra?: { | ||
// 翻译 | ||
translate: { | ||
target: string; | ||
to: string; | ||
}; | ||
// 语音 | ||
} & Record<string, any>; | ||
|
||
parentId?: string; | ||
// 引用 | ||
quotaId?: string; | ||
/** | ||
* 角色 | ||
* @description 消息发送者的角色 | ||
*/ | ||
role: LLMRoleType; | ||
} |
Oops, something went wrong.
6a230e2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lobe-ui – ./
lobe-ui.vercel.app
lobe-ui-git-master-lobehub.vercel.app
ui.lobehub.com
lobe-ui-lobehub.vercel.app