From 24e9ab7fc353ec22035d5ae8c57f98b3b81859c6 Mon Sep 17 00:00:00 2001 From: zinkey Date: Wed, 22 Aug 2018 16:45:43 +0800 Subject: [PATCH] fixed umi/link umi/router --- src/components/GlobalHeader/index.js | 2 +- src/components/SiderMenu/BaseMenu.js | 2 +- src/components/SiderMenu/SiderMenu.js | 2 +- src/components/SiderMenu/SliderMenu.js | 2 +- src/components/TopNavHeader/index.js | 2 +- src/layouts/Header.js | 8 ++++---- src/layouts/PageHeaderLayout.js | 2 +- src/layouts/UserLayout.js | 2 +- src/pages/404.js | 2 +- src/pages/Account/Center/Center.js | 11 ++++++----- src/pages/Account/Settings/Info.js | 5 ++--- src/pages/Dashboard/Workplace.js | 2 +- src/pages/Exception/403.js | 2 +- src/pages/Exception/404.js | 2 +- src/pages/Exception/500.js | 2 +- src/pages/Forms/StepForm/Step1.js | 4 ++-- src/pages/Forms/StepForm/Step2.js | 4 ++-- src/pages/Forms/StepForm/Step3.js | 6 +++--- src/pages/List/List.js | 10 +++++----- src/pages/User/Login.js | 2 +- src/pages/User/Register.js | 5 +++-- src/pages/User/RegisterResult.js | 2 +- 22 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index c31f2b89..83c161be 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { Icon, Divider } from 'antd'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Debounce from 'lodash-decorators/debounce'; import styles from './index.less'; import RightContent from './RightContent'; diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index e28d51f0..a2922409 100644 --- a/src/components/SiderMenu/BaseMenu.js +++ b/src/components/SiderMenu/BaseMenu.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { Menu, Icon } from 'antd'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import { formatMessage } from 'umi/locale'; import pathToRegexp from 'path-to-regexp'; import { urlToList } from '../_utils/pathTools'; diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 8c2f77d1..58077b77 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { Layout, Menu, Icon } from 'antd'; import pathToRegexp from 'path-to-regexp'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import styles from './index.less'; import { urlToList } from '../_utils/pathTools'; diff --git a/src/components/SiderMenu/SliderMenu.js b/src/components/SiderMenu/SliderMenu.js index 9ebfd445..4be37551 100644 --- a/src/components/SiderMenu/SliderMenu.js +++ b/src/components/SiderMenu/SliderMenu.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { Layout } from 'antd'; import pathToRegexp from 'path-to-regexp'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import styles from './index.less'; import BaseMenu, { getMenuMatches } from './BaseMenu'; import { urlToList } from '../_utils/pathTools'; diff --git a/src/components/TopNavHeader/index.js b/src/components/TopNavHeader/index.js index dc4a9e57..a68c1171 100644 --- a/src/components/TopNavHeader/index.js +++ b/src/components/TopNavHeader/index.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import RightContent from '../GlobalHeader/RightContent'; import BaseMenu from '../SiderMenu/BaseMenu'; import styles from './index.less'; diff --git a/src/layouts/Header.js b/src/layouts/Header.js index d297c888..77825be4 100644 --- a/src/layouts/Header.js +++ b/src/layouts/Header.js @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import { Layout, message } from 'antd'; import Animate from 'rc-animate'; import { connect } from 'dva'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import GlobalHeader from '@/components/GlobalHeader'; import TopNavHeader from '@/components/TopNavHeader'; import styles from './Header.less'; @@ -44,15 +44,15 @@ class HeaderView extends PureComponent { handleMenuClick = ({ key }) => { const { dispatch } = this.props; if (key === 'userCenter') { - dispatch(routerRedux.push('/account/center')); + router.push('/account/center'); return; } if (key === 'triggerError') { - dispatch(routerRedux.push('/exception/trigger')); + router.push('/exception/trigger'); return; } if (key === 'userinfo') { - dispatch(routerRedux.push('/account/settings/base')); + router.push('/account/settings/base'); return; } if (key === 'logout') { diff --git a/src/layouts/PageHeaderLayout.js b/src/layouts/PageHeaderLayout.js index eeaac5e0..4801264a 100644 --- a/src/layouts/PageHeaderLayout.js +++ b/src/layouts/PageHeaderLayout.js @@ -1,6 +1,6 @@ import React from 'react'; import { FormattedMessage } from 'umi/locale'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import PageHeader from '@/components/PageHeader'; import GridContent from './GridContent'; import styles from './PageHeaderLayout.less'; diff --git a/src/layouts/UserLayout.js b/src/layouts/UserLayout.js index 1ff6a42b..41e032dd 100644 --- a/src/layouts/UserLayout.js +++ b/src/layouts/UserLayout.js @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import { Icon } from 'antd'; import GlobalFooter from '@/components/GlobalFooter'; import styles from './UserLayout.less'; diff --git a/src/pages/404.js b/src/pages/404.js index a653ef17..dd01d4b1 100644 --- a/src/pages/404.js +++ b/src/pages/404.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Exception from '@/components/Exception'; export default () => ( diff --git a/src/pages/Account/Center/Center.js b/src/pages/Account/Center/Center.js index 903e2ed8..dbc17364 100644 --- a/src/pages/Account/Center/Center.js +++ b/src/pages/Account/Center/Center.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'dva'; -import { Link, routerRedux } from 'dva/router'; +import Link from 'umi/link'; +import router from 'umi/router'; import { Card, Row, Col, Icon, Avatar, Tag, Divider, Spin, Input } from 'antd'; import GridContent from '@/layouts/GridContent'; import styles from './Center.less'; @@ -36,16 +37,16 @@ export default class Center extends PureComponent { } onTabChange = key => { - const { dispatch, match } = this.props; + const { match } = this.props; switch (key) { case 'articles': - dispatch(routerRedux.push(`${match.url}/articles`)); + router.push(`${match.url}/articles`); break; case 'applications': - dispatch(routerRedux.push(`${match.url}/applications`)); + router.push(`${match.url}/applications`); break; case 'projects': - dispatch(routerRedux.push(`${match.url}/projects`)); + router.push(`${match.url}/projects`); break; default: break; diff --git a/src/pages/Account/Settings/Info.js b/src/pages/Account/Settings/Info.js index f53986f2..23cedd8d 100644 --- a/src/pages/Account/Settings/Info.js +++ b/src/pages/Account/Settings/Info.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { connect } from 'dva'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import { FormattedMessage } from 'umi/locale'; import { Menu } from 'antd'; import styles from './Info.less'; @@ -71,8 +71,7 @@ export default class Info extends Component { }; selectKey = ({ key }) => { - const { dispatch } = this.props; - dispatch(routerRedux.push(`/account/settings/${key}`)); + router.push(`/account/settings/${key}`); this.setState({ selectKey: key, }); diff --git a/src/pages/Dashboard/Workplace.js b/src/pages/Dashboard/Workplace.js index 986586e8..6d6e73a3 100644 --- a/src/pages/Dashboard/Workplace.js +++ b/src/pages/Dashboard/Workplace.js @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import moment from 'moment'; import { connect } from 'dva'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import { Row, Col, Card, List, Avatar } from 'antd'; import { Radar } from '@/components/Charts'; diff --git a/src/pages/Exception/403.js b/src/pages/Exception/403.js index c75724aa..addd50eb 100644 --- a/src/pages/Exception/403.js +++ b/src/pages/Exception/403.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { formatMessage } from 'umi/locale'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Exception from '@/components/Exception'; class Exception403 extends Component { diff --git a/src/pages/Exception/404.js b/src/pages/Exception/404.js index e9ecdff1..813632c9 100644 --- a/src/pages/Exception/404.js +++ b/src/pages/Exception/404.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { formatMessage } from 'umi/locale'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Exception from '@/components/Exception'; class Exception404 extends Component { diff --git a/src/pages/Exception/500.js b/src/pages/Exception/500.js index f85732e4..72d3679d 100644 --- a/src/pages/Exception/500.js +++ b/src/pages/Exception/500.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { formatMessage } from 'umi/locale'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Exception from '@/components/Exception'; class Exception500 extends Component { diff --git a/src/pages/Forms/StepForm/Step1.js b/src/pages/Forms/StepForm/Step1.js index 03062009..07c3b02e 100644 --- a/src/pages/Forms/StepForm/Step1.js +++ b/src/pages/Forms/StepForm/Step1.js @@ -1,7 +1,7 @@ import React, { Fragment } from 'react'; import { connect } from 'dva'; import { Form, Input, Button, Select, Divider } from 'antd'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import styles from './style.less'; const { Option } = Select; @@ -30,7 +30,7 @@ export default class Step1 extends React.PureComponent { type: 'form/saveStepFormData', payload: values, }); - dispatch(routerRedux.push('/form/step-form/confirm')); + router.push('/form/step-form/confirm'); } }); }; diff --git a/src/pages/Forms/StepForm/Step2.js b/src/pages/Forms/StepForm/Step2.js index 856ba7ee..fb6ad480 100644 --- a/src/pages/Forms/StepForm/Step2.js +++ b/src/pages/Forms/StepForm/Step2.js @@ -1,7 +1,7 @@ import React from 'react'; import { connect } from 'dva'; import { Form, Input, Button, Alert, Divider } from 'antd'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import { digitUppercase } from '@/utils/utils'; import styles from './style.less'; @@ -20,7 +20,7 @@ class Step2 extends React.PureComponent { const { form, data, dispatch, submitting } = this.props; const { getFieldDecorator, validateFields } = form; const onPrev = () => { - dispatch(routerRedux.push('/form/step-form/info')); + router.push('/form/step-form/info'); }; const onValidateForm = e => { e.preventDefault(); diff --git a/src/pages/Forms/StepForm/Step3.js b/src/pages/Forms/StepForm/Step3.js index 6b29dba1..5273a5d5 100644 --- a/src/pages/Forms/StepForm/Step3.js +++ b/src/pages/Forms/StepForm/Step3.js @@ -1,7 +1,7 @@ import React, { Fragment } from 'react'; import { connect } from 'dva'; import { Button, Row, Col } from 'antd'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import Result from '@/components/Result'; import styles from './style.less'; @@ -10,9 +10,9 @@ import styles from './style.less'; })) export default class Step3 extends React.PureComponent { render() { - const { dispatch, data } = this.props; + const { data } = this.props; const onFinish = () => { - dispatch(routerRedux.push('/form/step-form/info')); + router.push('/form/step-form/info'); }; const information = (
diff --git a/src/pages/List/List.js b/src/pages/List/List.js index 3c7aa9ee..7bad3488 100644 --- a/src/pages/List/List.js +++ b/src/pages/List/List.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { routerRedux } from 'dva/router'; +import router from 'umi/router'; import { connect } from 'dva'; import { Input } from 'antd'; import PageHeaderLayout from '@/layouts/PageHeaderLayout'; @@ -7,16 +7,16 @@ import PageHeaderLayout from '@/layouts/PageHeaderLayout'; @connect() export default class SearchList extends Component { handleTabChange = key => { - const { dispatch, match } = this.props; + const { match } = this.props; switch (key) { case 'articles': - dispatch(routerRedux.push(`${match.url}/articles`)); + router.push(`${match.url}/articles`); break; case 'applications': - dispatch(routerRedux.push(`${match.url}/applications`)); + router.push(`${match.url}/applications`); break; case 'projects': - dispatch(routerRedux.push(`${match.url}/projects`)); + router.push(`${match.url}/projects`); break; default: break; diff --git a/src/pages/User/Login.js b/src/pages/User/Login.js index 46278402..0184e491 100644 --- a/src/pages/User/Login.js +++ b/src/pages/User/Login.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { connect } from 'dva'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import { Checkbox, Alert, Icon } from 'antd'; import Login from '@/components/Login'; import styles from './Login.less'; diff --git a/src/pages/User/Register.js b/src/pages/User/Register.js index 50ab5bf0..7ea4c604 100644 --- a/src/pages/User/Register.js +++ b/src/pages/User/Register.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { connect } from 'dva'; -import { routerRedux, Link } from 'dva/router'; +import Link from 'umi/link'; +import router from 'umi/router'; import { Form, Input, Button, Select, Row, Col, Popover, Progress } from 'antd'; import styles from './Register.less'; @@ -39,7 +40,7 @@ export default class Register extends Component { const account = form.getFieldValue('mail'); if (register.status === 'ok') { dispatch( - routerRedux.push({ + router.push({ pathname: '/user/register-result', state: { account, diff --git a/src/pages/User/RegisterResult.js b/src/pages/User/RegisterResult.js index 28eca745..d0594c1e 100644 --- a/src/pages/User/RegisterResult.js +++ b/src/pages/User/RegisterResult.js @@ -1,6 +1,6 @@ import React from 'react'; import { Button } from 'antd'; -import { Link } from 'dva/router'; +import Link from 'umi/link'; import Result from '@/components/Result'; import styles from './RegisterResult.less'; -- GitLab