Skip to content

Commit

Permalink
add class component count support, add the basic hooks count support
Browse files Browse the repository at this point in the history
  • Loading branch information
Deng XiaoLong committed Oct 23, 2019
1 parent 081df68 commit facb1fe
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 407 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@
"dotenv-expand": "4.2.0",
"dva": "^2.6.0-beta.12",
"dva-loading": "^3.0.6",
"echarts": "^4.2.1",
"echarts-for-react": "^2.0.15-beta.0",
"esri-loader": "^2.10.0",
"history": "^4.9.0",
"js-sha256": "^0.9.0",
"less": "^3.9.0",
"less-loader": "^5.0.0",
"lodash": "^4.17.15",
"material-ui-pickers": "^2.2.4",
"mini-css-extract-plugin": "0.5.0",
"moment": "^2.24.0",
"notistack": "^0.8.9",
"prop-types": "^15.7.2",
"re-resizable": "^5.0.1",
Expand Down
Binary file modified public/static/media/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/static/media/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
}

// Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 443;
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 8081;
const HOST = process.env.HOST || '0.0.0.0';

if (process.env.HOST) {
Expand Down
25 changes: 19 additions & 6 deletions src/commons/menu.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { I18n } from 'react-i18nify';
import { isUrl } from '../utils/utils';

const menuData = [
{
name: I18n.t('menu.security.name'),
path: 'security',
name: 'Class Component',
path: 'class-component',
authority: [],
icon: 'Security',
icon: 'Code',
hideInMenu: false,
children: [
{
name: I18n.t('menu.security.children.userManagement'),
path: 'user',
name: '',
path: 'count',
authority: []
}
]
},
{
name: 'Hooks',
path: 'hooks',
authority: [],
icon: 'ThumbUpAlt',
hideInMenu: false,
children: [
{
name: '',
path: 'count',
authority: []
}
]
Expand Down
6 changes: 6 additions & 0 deletions src/commons/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export const getRouterData = app => {
'/home': {
component: dynamicWrapper(app, [], () => import('pages/Exception/Exception403'))
},
'/class-component/count': {
component: dynamicWrapper(app, [], () => import('pages/ClassComponent/Count'))
},
'/hooks/count': {
component: dynamicWrapper(app, [], () => import('pages/Hooks/Count'))
},
'/exception': {
component: dynamicWrapper(app, [], () => import('../layouts/ExceptionLayout'))
},
Expand Down
164 changes: 76 additions & 88 deletions src/layouts/BasicLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Typography from '@material-ui/core/Typography';
import AppBar from '@material-ui/core/AppBar';
import { FormatIndentDecrease, FormatIndentIncrease } from '@material-ui/icons';
import { connect, router, routerRedux } from 'dva';
import DocumentTitle from 'react-document-title';
import { getRoutes } from 'utils/utils';
import Authorized from 'utils/Authorized';
import { getMenuData } from 'commons/menu';
Expand Down Expand Up @@ -173,15 +172,6 @@ function BasicLayout(props) {
return pathInfo ? pathInfo.name || '' : '';
}

function getPageTitle() {
const { pathname } = location;
let title = 'IVH';
if (routerData[pathname] && routerData[pathname].name) {
title = `${routerData[pathname].name} - IVH`;
}
return title;
}

function isLoading() {
const pathInfo = routerData[location.pathname];
return !(pathInfo && pathInfo.noLoading);
Expand All @@ -195,87 +185,85 @@ function BasicLayout(props) {
const titleName = getPageName();
const isGlobalLoadingNotNeeded = isLoading();
return (
<DocumentTitle title={getPageTitle()}>
<div className={classes.wrapper}>
<div className={styles.snowMask} />
<CssBaseline />
<Drawer
variant="permanent"
classes={{
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose)
}}
open={open}
>
<div className={`${styles.toolbar_icon} ${open ? styles.toolbar_icon_active : ''}`}>
<div className={classes.logo_wrapper} onClick={handleGoHome}>
<div className={classes.logo}>
<img src="/static/media/logo.png" alt="IVH" />
</div>
{open && <div className={classes.icon_name}>React Hooks Share</div>}
<div className={classes.wrapper}>
<div className={styles.snowMask} />
<CssBaseline />
<Drawer
variant="permanent"
classes={{
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose)
}}
open={open}
>
<div className={`${styles.toolbar_icon} ${open ? styles.toolbar_icon_active : ''}`}>
<div className={classes.logo_wrapper} onClick={handleGoHome}>
<div className={classes.logo}>
<img src="/static/media/logo.png" alt="React" />
</div>
{open && <div className={classes.icon_name}>React Hooks Share</div>}
</div>
<Divider />
<ScrollBar style={{ overflow: 'hidden' }}>
<SiderMenu
expand={open}
location={location}
menuData={getMenuData()}
Authorized={Authorized}
onCollapse={onCollapse}
collapsed={!open}
/>
</div>
<Divider />
<ScrollBar style={{ overflow: 'hidden' }}>
<SiderMenu
expand={open}
location={location}
menuData={getMenuData()}
Authorized={Authorized}
onCollapse={onCollapse}
collapsed={!open}
/>
</ScrollBar>
</Drawer>
<main className={classes.main}>
{isGlobalLoadingNotNeeded && loading.global && <Loading />}
<AppBar position="static" color="inherit" className={classes.app_bar}>
<Typography variant="h6" color="inherit">
{open ? (
<IconButton
color="primary"
onClick={handleDrawerClose}
className={classes.expend_button}
>
<FormatIndentDecrease />
</IconButton>
) : (
<IconButton
color="primary"
onClick={handleDrawerOpen}
className={classes.expend_button}
>
<FormatIndentIncrease />
</IconButton>
)}
</Typography>
</AppBar>
<div className={classes.container}>
<ScrollBar className={classes.content}>
{titleName && <BasicLayoutTitle titleName={titleName} />}
<Switch>
{redirectData.map(item => (
<Redirect key={item.from} exact from={item.from} to={item.to} />
))}
{getRoutes(match.path, routerData).map(item => (
<Route
key={item.key}
path={item.path}
component={item.component}
exact={item.exact}
authority={item.authority}
redirectPath={isLogged ? '/home' : '/'}
theme={theme}
global={global}
/>
))}
<Redirect exact from="/" to={bashRedirect} />
<Route exact path="/home" />
</Switch>
</ScrollBar>
</Drawer>
<main className={classes.main}>
{isGlobalLoadingNotNeeded && loading.global && <Loading />}
<AppBar position="static" color="inherit" className={classes.app_bar}>
<Typography variant="h6" color="inherit">
{open ? (
<IconButton
color="primary"
onClick={handleDrawerClose}
className={classes.expend_button}
>
<FormatIndentDecrease />
</IconButton>
) : (
<IconButton
color="primary"
onClick={handleDrawerOpen}
className={classes.expend_button}
>
<FormatIndentIncrease />
</IconButton>
)}
</Typography>
</AppBar>
<div className={classes.container}>
<ScrollBar className={classes.content}>
{titleName && <BasicLayoutTitle titleName={titleName} />}
<Switch>
{redirectData.map(item => (
<Redirect key={item.from} exact from={item.from} to={item.to} />
))}
{getRoutes(match.path, routerData).map(item => (
<Route
key={item.key}
path={item.path}
component={item.component}
exact={item.exact}
authority={item.authority}
redirectPath={isLogged ? '/home' : '/'}
theme={theme}
global={global}
/>
))}
<Redirect exact from="/" to={bashRedirect} />
<Route exact path="/home" />
</Switch>
</ScrollBar>
</div>
</main>
</div>
</DocumentTitle>
</div>
</main>
</div>
);
}

Expand Down
Loading

0 comments on commit facb1fe

Please sign in to comment.