refactor: AlertErrorView 增加查看详情

pull/13/head
moonrailgun 4 years ago
parent 65991a6d43
commit 3e8e8870d6

@ -1,17 +1,37 @@
import React from 'react';
import { Alert } from 'antd';
import React, { useState } from 'react';
import { Alert, Button } from 'antd';
import clsx from 'clsx';
/**
*
*/
export const AlertErrorView: React.FC<{
error: Error;
}> = React.memo((props) => {
}> = React.memo(({ error }) => {
const [show, setShow] = useState(false);
const description = (
<div>
<span>{String(error.message)}</span>
<Button
className={clsx({
'opacity-0': show,
})}
type="link"
onClick={() => setShow(true)}
>
</Button>
{show && <pre>{String(error.stack)}</pre>}
</div>
);
return (
<Alert
className="w-full h-full select-text"
type="error"
message={String(props.error.name)}
description={String(props.error.message)}
message={String(error.name)}
description={description}
/>
);
});

Loading…
Cancel
Save