feat: support tachycode issue feedback

This commit is contained in:
sealday 2024-03-17 12:50:38 +08:00
parent 7de2f749b1
commit dbd5622f27
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,50 @@
import { Button, Result, Typography } from 'antd';
import React, { FC } from 'react';
import { FallbackProps, useErrorBoundary } from 'react-error-boundary';
import { Trans, useTranslation } from 'react-i18next';
const { Paragraph, Text, Link } = Typography;
export const ErrorFallback: FC<FallbackProps> = ({ error }) => {
const { resetBoundary } = useErrorBoundary();
const { t } = useTranslation();
const subTitle = (
<Trans>
{'This is likely a TachyCode internals bug. Please open an issue at '}
<Link href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues" target="_blank">
here
</Link>
</Trans>
);
return (
<div style={{ backgroundColor: 'white' }}>
<Result
style={{ maxWidth: '60vw', margin: 'auto' }}
status="error"
title={t('Render Failed')}
subTitle={subTitle}
extra={[
<Button
type="primary"
key="feedback"
href="https://git.daoyoucloud.com/daoyoucloud/tachycode/issues"
target="_blank"
>
{t('Feedback')}
</Button>,
<Button key="try" onClick={resetBoundary}>
{t('Try again')}
</Button>,
]}
>
<Paragraph copyable>
<Text type="danger" style={{ whiteSpace: 'pre-line', textAlign: 'center' }}>
{error.stack}
</Text>
</Paragraph>
</Result>
</div>
);
};

View File

@ -1 +1 @@
export * from './ErrorFallback';
export * from './ErrorFallback2';