Skip to content

Commit c924dc9

Browse files
committed
feat: 添加ExceptionBase组件
1 parent 7938bbb commit c924dc9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/components/ExceptionBase.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import SvgIcon from './SvgIcon';
2+
3+
type ExceptionType = '403' | '404' | '500';
4+
5+
interface Props {
6+
/**
7+
* Exception type
8+
*
9+
* - 403: no permission
10+
* - 404: not found
11+
* - 500: service error
12+
*/
13+
type: ExceptionType;
14+
}
15+
const iconMap: Record<ExceptionType, string> = {
16+
'403': 'no-permission',
17+
'404': 'not-found',
18+
'500': 'service-error'
19+
};
20+
const ExceptionBase: FC<Props> = memo(({ type }) => {
21+
const { t } = useTranslation();
22+
const nav = useNavigate();
23+
24+
const onClick = () => {
25+
nav('/');
26+
};
27+
28+
return (
29+
<div className="size-full min-h-520px flex-col-center gap-24px overflow-hidden">
30+
<div className="flex text-400px text-primary">
31+
<SvgIcon localIcon={iconMap[type]} />
32+
</div>
33+
<AButton
34+
type="primary"
35+
onClick={onClick}
36+
>
37+
{t('common.backToHome')}
38+
</AButton>
39+
</div>
40+
);
41+
});
42+
43+
export default ExceptionBase;

0 commit comments

Comments
 (0)