Browse Source

bugfix: Fix trigger page

陈帅 7 years atrás
parent
commit
b1ef8d423f

+ 1 - 1
config/config.js

@@ -95,7 +95,7 @@ export default {
         { path: '/exception/403', component: './Exception/403' },
         { path: '/exception/404', component: './Exception/404' },
         { path: '/exception/500', component: './Exception/500' },
-
+        { path: '/exception/trigger', component: './Exception/triggerException' },
         // account
         {
           path: '/account/center',

+ 1 - 1
src/components/GlobalHeader/RightContent.js

@@ -18,7 +18,6 @@ export default class GlobalHeaderRight extends PureComponent {
       if (newNotice.datetime) {
         newNotice.datetime = moment(notice.datetime).fromNow();
       }
-      // transform id to item key
       if (newNotice.id) {
         newNotice.key = newNotice.id;
       }
@@ -154,6 +153,7 @@ export default class GlobalHeaderRight extends PureComponent {
         )}
         <Button
           size="small"
+          ghost={theme === 'dark'}
           onClick={() => {
             this.changLang();
           }}

+ 2 - 0
src/models/login.js

@@ -40,9 +40,11 @@ export default {
         yield put(routerRedux.replace(redirect || '/'));
       }
     },
+
     *getCaptcha({ payload }, { call }) {
       yield call(getFakeCaptcha, payload);
     },
+
     *logout(_, { put }) {
       yield put({
         type: 'changeLoginStatus',

+ 7 - 0
src/pages/404.js

@@ -0,0 +1,7 @@
+import React from 'react';
+import { Link } from 'dva/router';
+import Exception from 'components/Exception';
+
+export default () => (
+  <Exception type="404" style={{ minHeight: 500, height: '80%' }} linkElement={Link} />
+);

+ 5 - 27
src/pages/layouts/BasicLayout.js

@@ -29,6 +29,7 @@ const { check } = Authorized;
  * @param {Object} routerData 路由配置
  */
 const getBreadcrumbNameMap = memoizeOne((meun, router) => {
+  console.log(meun, router);
   const routerMap = {};
   const mergeMeunAndRouter = meunData => {
     meunData.forEach(meunItem => {
@@ -71,6 +72,7 @@ class BasicLayout extends React.PureComponent {
   constructor(props) {
     super(props);
     const { routerData, menuData } = this.props;
+    this.getPageTitle = memoizeOne(this.getPageTitle);
     this.breadcrumbNameMap = getBreadcrumbNameMap(menuData, routerData);
   }
 
@@ -148,19 +150,14 @@ class BasicLayout extends React.PureComponent {
   };
 
   render() {
-    // TODO remove old router code
     const {
       isMobile,
-      // redirectData,
-      // routerData,
       silderTheme,
       layout: PropsLayout,
       children,
       location: { pathname },
     } = this.props;
     const isTop = PropsLayout === 'topmenu';
-    // const bashRedirect = this.getBashRedirect();
-    // const myRedirectData = redirectData || [];
     const layout = (
       <Layout>
         {isTop && !isMobile ? null : (
@@ -174,33 +171,14 @@ class BasicLayout extends React.PureComponent {
         )}
         <Layout style={this.getLayoutStyle()}>
           <Header handleMenuCollapse={this.handleMenuCollapse} logo={logo} {...this.props} />
-          <Content style={this.getContentStyle()}>
-            {children}
-            {/* <Switch> TODO remove
-              {myRedirectData.map(item => (
-                <Redirect key={item.from} exact from={item.from} to={item.to} />
-              ))}
-              {getRoutes(match.path, routerData).map(item => (
-                <AuthorizedRoute
-                  key={item.key}
-                  path={item.path}
-                  component={item.component}
-                  exact={item.exact}
-                  authority={item.authority}
-                  redirectPath="/exception/403"
-                />
-              ))}
-              <Redirect exact from="/" to={bashRedirect} />
-              <Route render={NotFound} />
-            </Switch> */}
-          </Content>
+          <Content style={this.getContentStyle()}>{children}</Content>
           <Footer />
         </Layout>
       </Layout>
     );
-    const getPageTitle = memoizeOne(this.getPageTitle);
+
     return (
-      <DocumentTitle title={getPageTitle(pathname)}>
+      <DocumentTitle title={this.getPageTitle(pathname)}>
         <ContainerQuery query={query}>
           {params => (
             <Context.Provider value={this.getContext()}>

+ 6 - 11
src/utils/request.js

@@ -1,11 +1,6 @@
 import fetch from 'dva/fetch';
 import { notification } from 'antd';
-import { routerRedux } from 'dva/router';
-
-// TODO set store
-// import store from '../global';
-// use global store
-const store = window.g_app._store
+import router from 'umi/router';
 
 const codeMessage = {
   200: '服务器成功返回请求的数据。',
@@ -81,24 +76,24 @@ export default function request(url, options) {
       return response.json();
     })
     .catch(e => {
-      const { dispatch } = store;
       const status = e.name;
       if (status === 401) {
-        dispatch({
+        /* eslint-disable no-underscore-dangle */
+        window.g_app._store.dispatch({
           type: 'login/logout',
         });
         return;
       }
       if (status === 403) {
-        dispatch(routerRedux.push('/exception/403'));
+        router.push('/exception/403');
         return;
       }
       if (status <= 504 && status >= 500) {
-        dispatch(routerRedux.push('/exception/500'));
+        router.push('/exception/500');
         return;
       }
       if (status >= 404 && status < 422) {
-        dispatch(routerRedux.push('/exception/404'));
+        router.push('/exception/404');
       }
     });
 }