Sfoglia il codice sorgente

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

* fix #4565,add 404 page

* fix codacy warning

* add 404 in fetch:blocks

* rm NoticeIconView import
陈帅 6 anni fa
parent
commit
243cc7e39a

+ 6 - 0
config/config.ts

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

+ 3 - 0
scripts/fetch-blocks.js

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

+ 1 - 0
src/components/NoticeIcon/NoticeList.tsx

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

+ 1 - 1
src/components/NoticeIcon/index.tsx

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

+ 1 - 0
src/models/global.ts

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

+ 24 - 0
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;