Skip to content

Commit 92542e7

Browse files
committed
refactor: routes
1 parent 0b146d2 commit 92542e7

7 files changed

Lines changed: 27 additions & 27 deletions

File tree

config/webpack.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const baseConfig = {
6868
*/
6969
// 第二项(入口文件):https://webpack.docschina.org/concepts/#%E5%85%A5%E5%8F%A3entry
7070
entry: {
71-
app: ['react-hot-loader/patch', resolvePath('src/index.tsx')],
71+
app: ['react-hot-loader/patch', resolvePath('src/main.tsx')],
7272
},
7373
/*
7474
https://webpack.docschina.org/concepts/#%E8%BE%93%E5%87%BAoutput
File renamed without changes.

src/pages/login/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useHistory } from 'react-router-dom';
55
import Footer from '@/components/footer';
66
import { HostName } from '../../api/config';
77
import * as AuthAction from '../../api/request/auth';
8-
import { LoginResponse } from '../../api/response/auth';
98
import { titleMap } from '../../utils';
109
import './login.less';
1110

@@ -16,14 +15,15 @@ export default function Page() {
1615
setLoginFlag(true);
1716
const { username = 'admin', password = '123456' } = values;
1817
try {
19-
const data: LoginResponse = await AuthAction.login({
18+
const resp: any = await AuthAction.login({
2019
username,
2120
password,
2221
});
23-
console.log('data=======:', data);
22+
const { success, data } = resp;
23+
if (!success) return;
2424
sessionStorage.setItem('token', data?.token);
2525
setLoginFlag(false);
26-
history.push('/main');
26+
history.push('/main', { replace: true });
2727
} catch (error) {
2828
setLoginFlag(false);
2929
console.log(error);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DatePicker } from 'antd';
2-
import { DateFormat } from '../typings/constant';
3-
import { dateFormatYMD } from '../utils';
4-
import '../styles/main.less';
2+
import { DateFormat } from '../../typings/constant';
3+
import { dateFormatYMD } from '../../utils';
4+
import './main.less';
55

66
const { RangePicker } = DatePicker;
77
export default function Main() {

src/routes.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import loadable from './utils/loadable';
2+
import AdminRouter from './pages/admin/router';
3+
import AuthRouter from './pages/auth/router';
4+
5+
const Main = loadable(() => import('./pages/main'));
6+
7+
const routes = [
8+
{
9+
path: '/main',
10+
name: 'Dashboard',
11+
exact: true,
12+
component: Main,
13+
auth: [1],
14+
},
15+
...AdminRouter,
16+
...AuthRouter,
17+
];
18+
19+
export default routes;

src/routes/index.ts

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

0 commit comments

Comments
 (0)