refactor: AlertErrorView 增加查看详情

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

@ -1,17 +1,37 @@
import React from 'react'; import React, { useState } from 'react';
import { Alert } from 'antd'; import { Alert, Button } from 'antd';
import clsx from 'clsx';
/** /**
* *
*/ */
export const AlertErrorView: React.FC<{ export const AlertErrorView: React.FC<{
error: Error; 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 ( return (
<Alert <Alert
className="w-full h-full select-text"
type="error" type="error"
message={String(props.error.name)} message={String(error.name)}
description={String(props.error.message)} description={description}
/> />
); );
}); });

Loading…
Cancel
Save