Skip to content

Commit a6f0209

Browse files
author
guosw
committed
pref: Project optimization in progress
1 parent 3933b89 commit a6f0209

File tree

25 files changed

+1605
-126
lines changed

25 files changed

+1605
-126
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"jest-watch-typeahead": "0.3.1",
3939
"marked": "^0.7.0",
4040
"mini-css-extract-plugin": "0.5.0",
41+
"mitt": "^1.2.0",
4142
"normalize.css": "^8.0.1",
4243
"optimize-css-assets-webpack-plugin": "5.0.3",
4344
"pnp-webpack-plugin": "1.5.0",

src/App.jsx

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
import React, { useEffect } from 'react'
22
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom'
3-
import { connect, useSelector, useDispatch } from 'react-redux'
3+
import { useSelector } from 'react-redux'
44

5+
// config
56
import routes from '@/routes'
6-
// import { getWindowWidth } from '@/redux/app/actions'
7-
import { getTagList, getCategoryList } from '@/redux/article/actions'
7+
8+
// components
9+
import PublicComponent from '@/components/Public'
810

911
const App = props => {
10-
const dispatch = useDispatch() // dispatch hooks
1112
const role = useSelector(state => state.user.role) // 相当于 connect(state => state.user.role)(App)
1213

13-
// 初始化数据 类似 componentDidMount
14-
useEffect(() => {
15-
// dispatch(getWindowWidth())
16-
dispatch(getTagList())
17-
dispatch(getCategoryList())
18-
// props.getWindowWidth()
19-
// props.getTagList()
20-
// props.getCategoryList()
21-
//
22-
console.log('app did mount')
23-
/*eslint react-hooks/exhaustive-deps: "off"*/
24-
}, [])
25-
2614
// 解构 route
2715
function renderRoutes(routes, contextPath) {
2816
const children = []
@@ -61,45 +49,11 @@ const App = props => {
6149
}
6250

6351
const children = renderRoutes(routes, '/')
64-
return <BrowserRouter>{children}</BrowserRouter>
52+
return (
53+
<BrowserRouter>
54+
{children}
55+
<PublicComponent />
56+
</BrowserRouter>)
6557
}
6658

6759
export default App
68-
69-
// export default connect(
70-
// state => ({
71-
// role: state.user.role
72-
// }),
73-
// { getWindowWidth, getTagList, getCategoryList }
74-
// )(App)
75-
76-
// example test
77-
// import WebLayout from '@/layout/web'
78-
// import AdminLayout from '@/layout/admin'
79-
// import Example from '@/views/examples'
80-
81-
// const App = () => {
82-
// return (
83-
// <BrowserRouter>
84-
// <Switch>
85-
// <Route path='/test' component={Example} />
86-
// <Route
87-
// path='/admin'
88-
// render={props => (
89-
// <AdminLayout>
90-
// <Route path='/admin/e' component={Example} exact />
91-
// </AdminLayout>
92-
// )}
93-
// />
94-
// <Route
95-
// path='/'
96-
// render={props => (
97-
// <WebLayout>
98-
// <Route path='/e' component={Example} />
99-
// </WebLayout>
100-
// )}
101-
// />
102-
// </Switch>
103-
// </BrowserRouter>
104-
// )
105-
// }

0 commit comments

Comments
 (0)