-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89e5d7c
commit 7902f92
Showing
4 changed files
with
79 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,59 @@ | ||
import { Button } from '@nextui-org/react' | ||
import { ReactNode } from 'react' | ||
import { ErrorBoundary, FallbackProps } from 'react-error-boundary' | ||
|
||
const ErrorFallback = ({ error }: FallbackProps): JSX.Element => { | ||
return ( | ||
<div className="p-4"> | ||
<h2 className="my-2 text-lg font-bold"> | ||
{'应用崩溃了 :( 请将以下信息提交给开发者以排查错误'} | ||
</h2> | ||
|
||
<Button | ||
size="sm" | ||
color="primary" | ||
variant="flat" | ||
onPress={() => open('https://github.com/pompurin404/mihomo-party/issues/new/choose')} | ||
> | ||
GitHub | ||
</Button> | ||
<Button | ||
size="sm" | ||
color="primary" | ||
variant="flat" | ||
className="ml-2" | ||
onPress={() => open('https://t.me/mihomo_party')} | ||
> | ||
Telegram | ||
</Button> | ||
|
||
<Button | ||
size="sm" | ||
variant="flat" | ||
className="ml-2" | ||
onPress={() => | ||
navigator.clipboard.writeText('```\n' + error.message + '\n' + error.stack + '\n```') | ||
} | ||
> | ||
复制报错信息 | ||
</Button> | ||
|
||
<p className="my-2">{error.message}</p> | ||
|
||
<details title="Error Stack"> | ||
<summary>Error Stack</summary> | ||
<pre>{error.stack}</pre> | ||
</details> | ||
</div> | ||
) | ||
} | ||
|
||
interface Props { | ||
children?: ReactNode | ||
} | ||
|
||
const BaseErrorBoundary = (props: Props): JSX.Element => { | ||
return <ErrorBoundary FallbackComponent={ErrorFallback}>{props.children}</ErrorBoundary> | ||
} | ||
|
||
export default BaseErrorBoundary |
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