Skip to content

Commit 34190a8

Browse files
committed
Code refactoring
1 parent 7241bfd commit 34190a8

File tree

12 files changed

+51
-50
lines changed

12 files changed

+51
-50
lines changed

reactjs/src/appInitializer.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

reactjs/src/components/Header/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Col, Icon, Avatar, Menu, Dropdown, Badge } from 'antd';
33
import { Link } from 'react-router-dom';
44
import LanguageSelect from '../LanguageSelect';
55
import './index.css';
6+
import { L } from 'src/lib/abpUtility';
67

78
export interface IHeaderProps {
89
collapsed?: any;
@@ -15,7 +16,7 @@ const userDropdownMenu = (
1516
<Icon type="logout" />
1617
<span>
1718
{' '}
18-
<Link to="/login">Logout</Link>
19+
<Link to="/logout">{L('Logout')}</Link>
1920
</span>
2021
</Menu.Item>
2122
</Menu>

reactjs/src/components/Layout/AppLayout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class AppLayout extends React.Component<any> {
2828
};
2929

3030
render() {
31-
debugger;
3231
const {
3332
history,
3433
location: { pathname },

reactjs/src/components/Layout/UserLayout.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import * as React from 'react';
22
import DocumentTitle from 'react-document-title';
33
import { Switch, Route, Redirect } from 'react-router-dom';
44
import utils from 'src/utils/utils';
5-
// import { userRouter } from '../Router/router.config';
6-
// import Login from 'src/scenes/Login';
75
import { userRouter } from '../Router/router.config';
86

97
class UserLayout extends React.Component<any> {
108
render() {
11-
debugger;
129
const {
1310
location: { pathname },
1411
} = this.props;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from 'react';
2+
import AuthenticationStore from 'src/stores/authenticationStore';
3+
import { inject } from 'mobx-react';
4+
import Stores from 'src/stores/storeIdentifier';
5+
6+
export interface ILogoutProps {
7+
authenticationStore?: AuthenticationStore;
8+
}
9+
10+
@inject(Stores.AuthenticationStore)
11+
class Logout extends React.Component<ILogoutProps> {
12+
componentDidMount() {
13+
this.props.authenticationStore!.logout();
14+
window.location.href = '/';
15+
}
16+
17+
render() {
18+
return null;
19+
}
20+
}
21+
22+
export default Logout;

reactjs/src/components/Router/ProtectedRoute.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { Route, Redirect } from 'react-router-dom';
44
// import { isGranted } from 'src/lib/abpUtility';
55

66
const ProtectedRoute = ({ path, component: Component, permission, render, ...rest }: any) => {
7-
debugger;
87
return (
98
<Route
109
{...rest}
1110
render={props => {
12-
debugger;
1311
if (!abp.session.userId)
1412
return (
1513
<Redirect

reactjs/src/components/Router/router.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export const userRouter: any = [
77
title: 'User',
88
component: LoadableComponent(() => import('src/components/Layout/UserLayout')),
99
isLayout: true,
10+
showInMenu: false,
1011
},
1112
{
1213
path: '/user/login',
1314
name: 'login',
1415
title: 'LogIn',
1516
component: LoadableComponent(() => import('src/scenes/Login')),
17+
showInMenu: false,
1618
},
1719
];
1820

@@ -26,13 +28,15 @@ export const appRouters: any = [
2628
icon: 'home',
2729
component: LoadableComponent(() => import('src/components/Layout/AppLayout')),
2830
isLayout: true,
31+
showInMenu: false,
2932
},
3033
{
3134
path: '/dashboard',
3235
name: 'dashboard',
3336
permission: '',
3437
title: 'Dashboard',
3538
icon: 'home',
39+
showInMenu: true,
3640
component: LoadableComponent(() => import('src/scenes/Dashboard')),
3741
},
3842
{
@@ -41,6 +45,7 @@ export const appRouters: any = [
4145
title: 'Users',
4246
name: 'user',
4347
icon: 'user',
48+
showInMenu: true,
4449
component: LoadableComponent(() => import('src/scenes/Users')),
4550
},
4651
{
@@ -49,6 +54,7 @@ export const appRouters: any = [
4954
title: 'Roles',
5055
name: 'role',
5156
icon: 'tags',
57+
showInMenu: true,
5258
component: LoadableComponent(() => import('src/scenes/Roles')),
5359
},
5460
{
@@ -57,6 +63,7 @@ export const appRouters: any = [
5763
title: 'Tenants',
5864
name: 'tenant',
5965
icon: 'appstore',
66+
showInMenu: true,
6067
component: LoadableComponent(() => import('src/scenes/Tenants')),
6168
},
6269
{
@@ -65,8 +72,18 @@ export const appRouters: any = [
6572
title: 'About',
6673
name: 'about',
6774
icon: 'info-circle',
75+
showInMenu: true,
6876
component: LoadableComponent(() => import('src/scenes/About')),
6977
},
78+
{
79+
path: '/logout',
80+
permission: '',
81+
title: 'Logout',
82+
name: 'logout',
83+
icon: 'info-circle',
84+
showInMenu: false,
85+
component: LoadableComponent(() => import('src/components/Logout')),
86+
},
7087
];
7188

7289
export const routers = [...userRouter, ...appRouters];

reactjs/src/components/SiderMenu/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const SiderMenu = (props: ISiderMenuProps) => {
3030

3131
<Menu theme="dark" mode="inline">
3232
{appRouters
33-
.filter((item: any) => !item.isLayout)
33+
.filter((item: any) => !item.isLayout && item.showInMenu)
3434
.map((route: any, index: number) => {
3535
if (route.permission && !isGranted(route.permission)) return null;
3636

reactjs/src/scenes/Login/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class Login extends React.Component<ILoginProps, any> {
4848
e.preventDefault();
4949
await this.props.form.validateFields(async (err: any, values: any) => {
5050
if (!err) {
51-
debugger;
5251
await this.props.authenticationStore!.login(values);
53-
debugger;
5452
sessionStorage.setItem('rememberMe', this.state.rememberMe ? '1' : '0');
5553
const { state } = this.props.location;
5654
window.location = state ? state.from.pathname : '/';

reactjs/src/services/httpService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ http.interceptors.response.use(
3939
title: L('LoginFailed'),
4040
content: error.response.data.error.message,
4141
});
42-
console.log(`title: Login Failed content:$`);
4342
} else if (!error.response) {
4443
Modal.error({ content: L('UnknownError') });
4544
}

0 commit comments

Comments
 (0)