generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: 支持自定义 Error 渲染 & 配套文档 (#155)
* ✨ feat: error support custom * 💚 fix: ci fixed
- Loading branch information
1 parent
c2e20ce
commit 0a5ce85
Showing
14 changed files
with
250 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* compact: true | ||
* iframe: 1000 | ||
*/ | ||
import { ProChat, ProChatInstance } from '@ant-design/pro-chat'; | ||
import { Button, Card, Result } from 'antd'; | ||
import { useTheme } from 'antd-style'; | ||
import { useEffect, useRef } from 'react'; | ||
import { MockResponse } from './mocks/streamResponse'; | ||
|
||
export default () => { | ||
const theme = useTheme(); | ||
|
||
const chatRef1 = useRef<ProChatInstance>(); | ||
|
||
useEffect(() => { | ||
setTimeout(() => { | ||
chatRef1.current.sendMessage('Hello!'); | ||
}, 500); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<div style={{ background: theme.colorBgLayout }}> | ||
<ProChat | ||
request={async () => { | ||
const mockResponse = new MockResponse('', 1000, true); | ||
return mockResponse.getResponse(); | ||
}} | ||
chatRef={chatRef1} | ||
style={{ height: 500 }} | ||
renderErrorMessages={(errorResponse) => { | ||
return ( | ||
<Card> | ||
<Result | ||
status="error" | ||
title="Something Error" | ||
subTitle={errorResponse.message} | ||
extra={[ | ||
<Button type="primary" key="console"> | ||
Try Again | ||
</Button>, | ||
<Button key="buy">Buy Token</Button>, | ||
]} | ||
/> | ||
</Card> | ||
); | ||
}} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; |
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,29 @@ | ||
/** | ||
* compact: true | ||
*/ | ||
import { ProChat, ProChatInstance } from '@ant-design/pro-chat'; | ||
import { useTheme } from 'antd-style'; | ||
import { useEffect, useRef } from 'react'; | ||
|
||
export default () => { | ||
const theme = useTheme(); | ||
|
||
const chatRef1 = useRef<ProChatInstance>(); | ||
|
||
useEffect(() => { | ||
chatRef1.current.sendMessage('Hello!'); | ||
}); | ||
|
||
return ( | ||
<> | ||
<div style={{ background: theme.colorBgLayout }}> | ||
<ProChat | ||
chatRef={chatRef1} | ||
request={async () => { | ||
return new Response('token 长度超限', { status: 500, statusText: 'limited of token' }); | ||
}} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; |
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
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
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,5 +1,5 @@ | ||
/** | ||
* iframe: 800 | ||
* iframe: 1000 | ||
* compact: true | ||
*/ | ||
import { ProChat } from '@ant-design/pro-chat'; | ||
|
Oops, something went wrong.