From da4bd1169c61cde75b9bfae56b7da6b193016354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E9=81=93?= Date: Wed, 11 Jul 2018 13:30:09 +0800 Subject: [PATCH] add account settings --- config/config.js | 28 ++++++++++++++------------ src/common/menu.js | 2 +- src/pages/Account/Settings/BaseView.js | 4 ++++ src/pages/layouts/BlankLayout.js | 3 --- src/pages/layouts/LoadingPage.js | 5 ++++- src/pages/layouts/index.js | 23 --------------------- 6 files changed, 24 insertions(+), 41 deletions(-) delete mode 100644 src/pages/layouts/BlankLayout.js delete mode 100644 src/pages/layouts/index.js diff --git a/config/config.js b/config/config.js index d54d27e9..294f39cd 100644 --- a/config/config.js +++ b/config/config.js @@ -26,7 +26,7 @@ export default { routes: [ { path: '/', - component: './layouts/index', + component: './layouts/LoadingPage', routes: [ // dashboard { path: '/', redirect: '/dashboard/analysis' }, @@ -77,31 +77,33 @@ export default { { path: '/exception/404', component: './Exception/404' }, { path: '/exception/500', component: './Exception/500' }, - // acount + // account { - path: '/acount/center', + path: '/account/center', component: './Account/Center/Center', routes: [ - { path: '/acount/center', redirect: '/acount/center/articles' }, - { path: '/acount/center/articles', component: './Account/Center/Articles' }, - { path: '/acount/center/applications', component: './Account/Center/Applications' }, - { path: '/acount/center/projects', component: './Account/Center/Projects' }, + { path: '/account/center', redirect: '/account/center/articles' }, + { path: '/account/center/articles', component: './Account/Center/Articles' }, + { path: '/account/center/applications', component: './Account/Center/Applications' }, + { path: '/account/center/projects', component: './Account/Center/Projects' }, ], }, { - path: '/acount/settings', + path: '/account/settings', component: './Account/Settings/Info', routes: [ - { path: '/acount/settings', redirect: '/acount/settings/base' }, - { path: '/acount/center/base', component: './Account/Settings/BaseView' }, - { path: '/acount/center/security', component: './Account/Settings/SecurityView' }, - { path: '/acount/center/binding', component: './Account/Settings/BindingView' }, + { path: '/account/settings', redirect: '/account/settings/base' }, + { path: '/account/settings/base', component: './Account/Settings/BaseView' }, + { path: '/account/settings/security', component: './Account/Settings/SecurityView' }, + { path: '/account/settings/binding', component: './Account/Settings/BindingView' }, { - path: '/acount/center/notification', + path: '/account/settings/notification', component: './Account/Settings/NotificationView', }, ], }, + + // user ], }, ], diff --git a/src/common/menu.js b/src/common/menu.js index 4fc7ffc1..ebb219e4 100644 --- a/src/common/menu.js +++ b/src/common/menu.js @@ -352,7 +352,7 @@ const menuData = [ { name: '个人页', icon: 'user', - path: 'acount', + path: 'account', children: [ { name: '个人中心', diff --git a/src/pages/Account/Settings/BaseView.js b/src/pages/Account/Settings/BaseView.js index e23bbc1f..b6fe2c50 100644 --- a/src/pages/Account/Settings/BaseView.js +++ b/src/pages/Account/Settings/BaseView.js @@ -1,5 +1,6 @@ import React, { Component, Fragment } from 'react'; import { Form, Input, Upload, Select, Button } from 'antd'; +import { connect } from 'dva'; import styles from './BaseView.less'; import GeographicView from './GeographicView'; import PhoneView from './PhoneView'; @@ -44,6 +45,9 @@ const validatorPhone = (rule, value, callback) => { callback(); }; +@connect(({ user }) => ({ + currentUser: user.currentUser, +})) @Form.create() export default class BaseView extends Component { componentDidMount() { diff --git a/src/pages/layouts/BlankLayout.js b/src/pages/layouts/BlankLayout.js deleted file mode 100644 index 85ea739f..00000000 --- a/src/pages/layouts/BlankLayout.js +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react'; - -export default props =>
; diff --git a/src/pages/layouts/LoadingPage.js b/src/pages/layouts/LoadingPage.js index 45c3e720..e277e70c 100644 --- a/src/pages/layouts/LoadingPage.js +++ b/src/pages/layouts/LoadingPage.js @@ -3,12 +3,14 @@ import { Spin } from 'antd'; import { connect } from 'dva'; import { enquireScreen, unenquireScreen } from 'enquire-js'; import BasicLayout from './BasicLayout'; -import { getMenuData } from '../common/menu'; +import { getMenuData } from '../../common/menu'; +import { getRouterData } from '../../common/router'; /** * 根据菜单取得重定向地址. */ const MenuData = getMenuData(); +const routerData = getRouterData({}); const getRedirectData = () => { const redirectData = []; const getRedirect = item => { @@ -90,6 +92,7 @@ class LoadingPage extends PureComponent { diff --git a/src/pages/layouts/index.js b/src/pages/layouts/index.js deleted file mode 100644 index cee343f0..00000000 --- a/src/pages/layouts/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { getRouterData } from 'common/router'; -import { getMenuData } from 'common/menu'; -import BasecLayout from './BasicLayout'; -import BlankLayout from './BlankLayout'; - -// TODO routerData menuData etc... -const openPages = ['/User', '/User/Login', '/User/Register', '/User/RegisterResult']; -export default props => { - const { children, location } = props; - const routerData = getRouterData({}); - const menuData = getMenuData({}); - let { pathname } = location; - pathname = pathname.startsWith('/') ? pathname : `/${pathname}`; - if (openPages && openPages.includes(pathname)) { - return {children}; - } - return ( - - {children} - - ); -}; -- GitLab