Browse Source

feat : fix #4565, add 404 page (#4588)

* fix #4565,add 404 page

* fix codacy warning

* add 404 in fetch:blocks

* rm NoticeIconView import
pull/4592/head
陈帅 7 years ago
committed by GitHub
parent
commit
243cc7e39a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      config/config.ts
  2. 3
      scripts/fetch-blocks.js
  3. 1
      src/components/NoticeIcon/NoticeList.tsx
  4. 2
      src/components/NoticeIcon/index.tsx
  5. 1
      src/models/global.ts
  6. 24
      src/pages/404.tsx

6
config/config.ts

@ -93,8 +93,14 @@ export default {
icon: 'smile', icon: 'smile',
component: './Welcome', component: './Welcome',
}, },
{
component: './404',
},
], ],
}, },
{
component: './404',
},
], ],
// Theme for antd: https://ant.design/docs/react/customize-theme-cn // Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: { theme: {

3
scripts/fetch-blocks.js

@ -41,6 +41,9 @@ const findAllInstallRouter = router => {
const filterParentRouter = (router, layout) => { const filterParentRouter = (router, layout) => {
return [...router] return [...router]
.map(item => { .map(item => {
if (!item.path && item.component === '404') {
return item;
}
if (item.routes && (!router.component || layout)) { if (item.routes && (!router.component || layout)) {
return { ...item, routes: filterParentRouter(item.routes, false) }; return { ...item, routes: filterParentRouter(item.routes, false) };
} }

1
src/components/NoticeIcon/NoticeList.tsx

@ -19,6 +19,7 @@ export interface NoticeIconTabProps {
emptyText?: string; emptyText?: string;
clearText?: string; clearText?: string;
viewMoreText?: string; viewMoreText?: string;
list: NoticeIconData[];
onViewMore?: (e: any) => void; onViewMore?: (e: any) => void;
} }
const NoticeList: React.SFC<NoticeIconTabProps> = ({ const NoticeList: React.SFC<NoticeIconTabProps> = ({

2
src/components/NoticeIcon/index.tsx

@ -117,7 +117,7 @@ export default class NoticeIcon extends Component<NoticeIconProps> {
}, },
); );
return ( return (
<Spin spinning={loading} delay={0}> <Spin spinning={loading} delay={300}>
<Tabs className={styles.tabs} onChange={this.onTabChange}> <Tabs className={styles.tabs} onChange={this.onTabChange}>
{panes} {panes}
</Tabs> </Tabs>

1
src/models/global.ts

@ -7,6 +7,7 @@ import { queryNotices } from '@/services/user';
export interface NoticeItem extends NoticeIconData { export interface NoticeItem extends NoticeIconData {
id: string; id: string;
type: string; type: string;
status: string;
} }
export interface GlobalModelState { export interface GlobalModelState {

24
src/pages/404.tsx

@ -0,0 +1,24 @@
import React from 'react';
import { Button } from 'antd';
// 这里应该使用 antd 的 404 result 组件,
// 但是还没发布,先来个简单的。
const NoFoundPage: React.FC<{}> = () => (
<div
style={{
height: '100vh',
padding: 80,
textAlign: 'center',
}}
>
<img src="https://gw.alipayobjects.com/zos/antfincdn/wsE2Pw%243%26L/noFound.svg" alt="404" />
<br />
<br />
<h1>404</h1>
<p>Sorry, the page you visited does not exist.</p>
<Button type="primary">Back Home</Button>
</div>
);
export default NoFoundPage;
Loading…
Cancel
Save