Browse Source

fix: wrap error Result in Card, style OfflineBanner with margin and showIcon

- ErrorBoundary: wrap Result in <Card variant="borderless"> for proper
  card styling
- OfflineBanner: remove `banner` prop (was causing header layout issues),
  add `showIcon` for warning icon, add `marginBottom: 16` for spacing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
pull/11756/head
afc163 5 months ago
parent
commit
8a8f6c9cc4
  1. 68
      src/components/ErrorBoundary/index.tsx
  2. 3
      src/components/OfflineBanner/index.tsx

68
src/components/ErrorBoundary/index.tsx

@ -1,5 +1,5 @@
import { getIntl } from '@umijs/max'; import { getIntl } from '@umijs/max';
import { Button, Result } from 'antd'; import { Button, Card, Result } from 'antd';
import React from 'react'; import React from 'react';
function isChunkLoadError(error: Error): boolean { function isChunkLoadError(error: Error): boolean {
@ -27,38 +27,40 @@ function renderErrorFallback(
const isChunkError = isChunkLoadError(error); const isChunkError = isChunkLoadError(error);
return ( return (
<Result <Card variant="borderless">
status="error" <Result
title={intl.formatMessage({ status="error"
id: isChunkError ? 'app.error.chunk.title' : 'app.error.render.title', title={intl.formatMessage({
defaultMessage: isChunkError id: isChunkError ? 'app.error.chunk.title' : 'app.error.render.title',
? 'Failed to load page' defaultMessage: isChunkError
: 'Something went wrong', ? 'Failed to load page'
})} : 'Something went wrong',
subTitle={intl.formatMessage({ })}
id: getSubTitleId(isChunkError, isOffline), subTitle={intl.formatMessage({
defaultMessage: id: getSubTitleId(isChunkError, isOffline),
isChunkError && isOffline defaultMessage:
? 'Your network connection has been lost. Please check your connection and refresh.' isChunkError && isOffline
: isChunkError ? 'Your network connection has been lost. Please check your connection and refresh.'
? 'Page resources failed to load. Please refresh and try again.' : isChunkError
: 'Sorry, an error occurred on this page. Please refresh or go back to the home page.', ? 'Page resources failed to load. Please refresh and try again.'
})} : 'Sorry, an error occurred on this page. Please refresh or go back to the home page.',
extra={[ })}
<Button type="primary" key="retry" onClick={onRetry}> extra={[
{intl.formatMessage({ <Button type="primary" key="retry" onClick={onRetry}>
id: 'app.error.retry', {intl.formatMessage({
defaultMessage: 'Refresh', id: 'app.error.retry',
})} defaultMessage: 'Refresh',
</Button>, })}
<Button href="/" key="home"> </Button>,
{intl.formatMessage({ <Button href="/" key="home">
id: 'app.error.home', {intl.formatMessage({
defaultMessage: 'Back Home', id: 'app.error.home',
})} defaultMessage: 'Back Home',
</Button>, })}
]} </Button>,
/> ]}
/>
</Card>
); );
} }

3
src/components/OfflineBanner/index.tsx

@ -23,8 +23,9 @@ const OfflineBanner: React.FC = () => {
return ( return (
<Alert <Alert
type="warning" type="warning"
banner showIcon
closable={false} closable={false}
style={{ marginBottom: 16 }}
message={getIntl().formatMessage({ message={getIntl().formatMessage({
id: 'app.network.offline', id: 'app.network.offline',
defaultMessage: defaultMessage:

Loading…
Cancel
Save