diff --git a/config/config.js b/config/config.js index 6c3d0367ddef5deaa112254b3eb50de8f6069494..6069a83ff670c2ab39f5e02a66293031f665d70a 100644 --- a/config/config.js +++ b/config/config.js @@ -5,10 +5,21 @@ const path = require('path'); export default { - plugins: ['umi-plugin-dva'], + // add for transfer to umi + plugins: [ + 'umi-plugin-dva', + [ + 'umi-plugin-routes', + { + exclude: [/\.test\.js/], + }, + ], + ], + disableServiceWorker: true, - // TODO remove - // entry: 'src/index.js', + // copy from old webpackrc.js + + // entry: 'src/index.js', // TODO remove extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]], env: { development: { @@ -21,7 +32,7 @@ export default { rollbar: 'rollbar', }, alias: { - components: path.resolve(__dirname, 'src/components/'), + components: path.resolve(__dirname, '../src/components/'), }, ignoreMomentLocale: true, theme: './src/theme.js', diff --git a/package.json b/package.json index 89f7237997d8d31103f67f41808bb13a7a5108cf..3da7c3aee2c6e89ecdca24320e9230fd30950828 100755 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "rollup-plugin-json": "^3.0.0", "setprototypeof": "^1.1.0", "umi": "^1.3.13", + "umi-plugin-routes": "^0.1.5", "url-polyfill": "^1.0.10" }, "devDependencies": { diff --git a/src/common/router.js b/src/common/router.js index edc7d998db5d0a2c45ce9a63d8c00a34162bd2e4..8e216ee824db0ac31f349f742d608b3f8e2168ae 100644 --- a/src/common/router.js +++ b/src/common/router.js @@ -75,142 +75,140 @@ export const getRouterData = app => { ), }, '/dashboard/analysis': { - component: dynamicWrapper(app, ['chart'], () => import('../routes/Dashboard/Analysis')), + component: dynamicWrapper(app, ['chart'], () => import('../pages/Dashboard/Analysis')), }, '/dashboard/monitor': { - component: dynamicWrapper(app, ['monitor'], () => import('../routes/Dashboard/Monitor')), + component: dynamicWrapper(app, ['monitor'], () => import('../pages/Dashboard/Monitor')), }, '/dashboard/workplace': { component: dynamicWrapper(app, ['user', 'project', 'activities', 'chart'], () => - import('../routes/Dashboard/Workplace') + import('../pages/Dashboard/Workplace') ), // hideInBreadcrumb: true, // name: '工作台', // authority: 'admin', }, '/form/basic-form': { - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/BasicForm')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/BasicForm')), }, '/form/step-form': { - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm')), }, '/form/step-form/info': { name: '分步表单(填写转账信息)', - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm/Step1')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step1')), }, '/form/step-form/confirm': { name: '分步表单(确认转账信息)', - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm/Step2')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step2')), }, '/form/step-form/result': { name: '分步表单(完成)', - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/StepForm/Step3')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step3')), }, '/form/advanced-form': { - component: dynamicWrapper(app, ['form'], () => import('../routes/Forms/AdvancedForm')), + component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/AdvancedForm')), }, '/list/table-list': { - component: dynamicWrapper(app, ['rule'], () => import('../routes/List/TableList')), + component: dynamicWrapper(app, ['rule'], () => import('../pages/List/TableList')), }, '/list/basic-list': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/BasicList')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/BasicList')), }, '/list/card-list': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/CardList')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/CardList')), }, '/list/search': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/List')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/List')), }, '/list/search/projects': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/Projects')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/Projects')), }, '/list/search/applications': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/Applications')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/Applications')), }, '/list/search/articles': { - component: dynamicWrapper(app, ['list'], () => import('../routes/List/Articles')), + component: dynamicWrapper(app, ['list'], () => import('../pages/List/Articles')), }, '/profile/basic': { - component: dynamicWrapper(app, ['profile'], () => import('../routes/Profile/BasicProfile')), + component: dynamicWrapper(app, ['profile'], () => import('../pages/Profile/BasicProfile')), }, '/profile/advanced': { - component: dynamicWrapper(app, ['profile'], () => - import('../routes/Profile/AdvancedProfile') - ), + component: dynamicWrapper(app, ['profile'], () => import('../pages/Profile/AdvancedProfile')), }, '/result/success': { - component: dynamicWrapper(app, [], () => import('../routes/Result/Success')), + component: dynamicWrapper(app, [], () => import('../pages/Result/Success')), }, '/result/fail': { - component: dynamicWrapper(app, [], () => import('../routes/Result/Error')), + component: dynamicWrapper(app, [], () => import('../pages/Result/Error')), }, '/exception/403': { - component: dynamicWrapper(app, [], () => import('../routes/Exception/403')), + component: dynamicWrapper(app, [], () => import('../pages/Exception/403')), }, '/exception/404': { - component: dynamicWrapper(app, [], () => import('../routes/Exception/404')), + component: dynamicWrapper(app, [], () => import('../pages/Exception/404')), }, '/exception/500': { - component: dynamicWrapper(app, [], () => import('../routes/Exception/500')), + component: dynamicWrapper(app, [], () => import('../pages/Exception/500')), }, '/exception/trigger': { component: dynamicWrapper(app, ['error'], () => - import('../routes/Exception/triggerException') + import('../pages/Exception/triggerException') ), }, '/user': { component: dynamicWrapper(app, [], () => import('../layouts/UserLayout')), }, '/user/login': { - component: dynamicWrapper(app, ['login'], () => import('../routes/User/Login')), + component: dynamicWrapper(app, ['login'], () => import('../pages/User/Login')), }, '/user/register': { - component: dynamicWrapper(app, ['register'], () => import('../routes/User/Register')), + component: dynamicWrapper(app, ['register'], () => import('../pages/User/Register')), }, '/user/register-result': { - component: dynamicWrapper(app, [], () => import('../routes/User/RegisterResult')), + component: dynamicWrapper(app, [], () => import('../pages/User/RegisterResult')), }, '/account/center': { component: dynamicWrapper(app, ['list', 'user', 'project'], () => - import('../routes/Account/Center/Center') + import('../pages/Account/Center/Center') ), }, '/account/center/articles': { - component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Articles')), + component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Articles')), }, '/account/center/applications': { - component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Applications')), + component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Applications')), }, '/account/center/projects': { - component: dynamicWrapper(app, [], () => import('../routes/Account/Center/Projects')), + component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Projects')), }, '/account/settings': { component: dynamicWrapper(app, ['geographic'], () => - import('../routes/Account/Settings/Info') + import('../pages/Account/Settings/Info') ), }, '/account/settings/base': { component: dynamicWrapper(app, ['geographic'], () => - import('../routes/Account/Settings/BaseView') + import('../pages/Account/Settings/BaseView') ), }, '/account/settings/security': { component: dynamicWrapper(app, ['geographic'], () => - import('../routes/Account/Settings/SecurityView') + import('../pages/Account/Settings/SecurityView') ), }, '/account/settings/binding': { component: dynamicWrapper(app, ['geographic'], () => - import('../routes/Account/Settings/BindingView') + import('../pages/Account/Settings/BindingView') ), }, '/account/settings/notification': { component: dynamicWrapper(app, ['geographic'], () => - import('../routes/Account/Settings/NotificationView') + import('../pages/Account/Settings/NotificationView') ), }, // '/user/:id': { - // component: dynamicWrapper(app, [], () => import('../routes/User/SomeComponent')), + // component: dynamicWrapper(app, [], () => import('../pages/User/SomeComponent')), // }, }; // Get name from ./menu.js or just set it in the router data. diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 608d62c164e489512ff5bed1f3917d9a3fde1cce..7fda5f12248024eec5565e9968efd075c26bea15 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -7,7 +7,7 @@ import { ContainerQuery } from 'react-container-query'; import classNames from 'classnames'; import pathToRegexp from 'path-to-regexp'; import SiderMenu from '../components/SiderMenu'; -import NotFound from '../routes/Exception/404'; +import NotFound from '../pages/Exception/404'; import { getRoutes } from '../utils/utils'; import Authorized from '../utils/Authorized'; import SettingDarwer from '../components/SettingDarwer'; diff --git a/src/models/index.js b/src/models/index.js deleted file mode 100644 index 902cb5cbc5e35aa10c284c4e7afb8811b27efadb..0000000000000000000000000000000000000000 --- a/src/models/index.js +++ /dev/null @@ -1,7 +0,0 @@ -// Use require.context to require reducers automatically -// Ref: https://webpack.js.org/guides/dependency-management/#require-context -const context = require.context('./', false, /\.js$/); -export default context - .keys() - .filter(item => item !== './index.js') - .map(key => context(key)); diff --git a/src/pages/Account/Center.js b/src/pages/Account/Center.js deleted file mode 100644 index 006b1f17bdab313e3eaabc0e68bc39da21433fa0..0000000000000000000000000000000000000000 --- a/src/pages/Account/Center.js +++ /dev/null @@ -1,414 +0,0 @@ -import React, { PureComponent } from 'react'; -import { connect } from 'dva'; -import { Link } from 'dva/router'; -import moment from 'moment'; -import numeral from 'numeral'; -import { - List, - Card, - Row, - Col, - Icon, - Dropdown, - Menu, - Avatar, - Tag, - Divider, - Tooltip, - Spin, - Input, -} from 'antd'; -import AvatarList from '../../components/AvatarList'; -import { formatWan } from '../../utils/utils'; -import stylesProjects from '../List/Projects.less'; -import styles from './Center.less'; -import stylesArticles from '../List/Articles.less'; -import stylesApplications from '../List/Applications.less'; -import GridContent from '../../layouts/GridContent'; - -@connect(({ list, loading, user, project }) => ({ - list, - listLoading: loading.effects['list/fetch'], - currentUser: user.currentUser, - currentUserLoading: loading.effects['user/fetchCurrent'], - project, - projectLoading: loading.effects['project/fetchNotice'], -})) -export default class Center extends PureComponent { - state = { - key: 'article', - newTags: [], - inputVisible: false, - inputValue: '', - }; - - componentDidMount() { - const { dispatch } = this.props; - dispatch({ - type: 'user/fetchCurrent', - }); - dispatch({ - type: 'list/fetch', - payload: { - count: 8, - }, - }); - dispatch({ - type: 'project/fetchNotice', - }); - } - - onTabChange = key => { - this.setState({ key }); - }; - - showInput = () => { - this.setState({ inputVisible: true }, () => this.input.focus()); - }; - - saveInputRef = input => { - this.input = input; - }; - - handleInputChange = e => { - this.setState({ inputValue: e.target.value }); - }; - - handleInputConfirm = () => { - const { state } = this; - const { inputValue } = state; - let { newTags } = state; - if (inputValue && newTags.filter(tag => tag.label === inputValue).length === 0) { - newTags = [...newTags, { key: `new-${newTags.length}`, label: inputValue }]; - } - this.setState({ - newTags, - inputVisible: false, - inputValue: '', - }); - }; - - renderArticles = (list, loading) => { - const IconText = ({ type, text }) => ( - - - {text} - - ); - const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => ( -
-
{content}
-
- - {owner} 发布在 {href} - {moment(updatedAt).format('YYYY-MM-DD HH:mm')} -
-
- ); - return ( - ( - , - , - , - ]} - > - - {item.title} - - } - description={ - - Ant Design - 设计语言 - 蚂蚁金服 - - } - /> - - - )} - /> - ); - }; - - renderApplications = (list, loading) => { - const itemMenu = ( - - - - 1st menu item - - - - - 2nd menu item - - - - - 3d menu item - - - - ); - const CardInfo = ({ activeUser, newUser }) => ( -
-
-

活跃用户

-

{activeUser}

-
-
-

新增用户

-

{newUser}

-
-
- ); - return ( - ( - - - - , - - - , - - - , - - - , - ]} - > - } title={item.title} /> -
- -
-
-
- )} - /> - ); - }; - - renderProjects = (list, loading) => { - return ( - ( - - } - > - {item.title}} description={item.subDescription} /> -
- {moment(item.updatedAt).fromNow()} -
- - {item.members.map(member => ( - - ))} - -
-
-
-
- )} - /> - ); - }; - - renderContent() { - const { newTags, inputVisible, inputValue } = this.state; - const { - currentUser, - project: { notice }, - projectLoading, - } = this.props; - return ( -
-
- -
{currentUser.name}
-
{currentUser.signature}
-
-
-

- - {currentUser.title} -

-

- - {currentUser.group} -

-

- - {currentUser.geographic.province.label} - {currentUser.geographic.city.label} -

-
- -
-
标签
- {currentUser.tags.map(item => {item.label})} - - - -
- -
-
团队
- - - {notice.map(item => ( - - - {item.member} - - ))} - - -
- -
-
标签
- {currentUser.tags.concat(newTags).map(item => {item.label})} - {inputVisible && ( - - )} - {!inputVisible && ( - - - - )} -
- -
-
团队
- - - {notice.map(item => ( - - - - {item.member} - - - ))} - - -
-
- ); - } - - render() { - const { - list: { list }, - listLoading, - currentUser, - currentUserLoading, - } = this.props; - const operationTabList = [ - { - key: 'article', - tab: ( - - 文章 (8) - - ), - }, - { - key: 'application', - tab: ( - - 应用 (8) - - ), - }, - { - key: 'project', - tab: ( - - 项目 (8) - - ), - }, - ]; - const contentMap = { - article: this.renderArticles(list, listLoading), - application: this.renderApplications(list, listLoading), - project: this.renderProjects(list, listLoading), - }; - const { key } = this.state; - return ( - -
- - - - {currentUser && Object.keys(currentUser).length - ? this.renderContent() - : 'loading...'} - - - - - {contentMap[key]} - - - -
-
- ); - } -}