-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
355 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PUBLIC_URL = '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { | ||
override, | ||
addWebpackAlias | ||
} = require("customize-cra") | ||
|
||
const path = require("path") | ||
// const resolve = dir => path.join(__dirname, dir) | ||
function resolve(dir) { | ||
return path.join(__dirname, dir) | ||
} | ||
|
||
module.exports = override( | ||
// 配置路径别名 | ||
addWebpackAlias({ | ||
"@": resolve("src") | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
import request from '../utils/request' | ||
|
||
// 登录 | ||
export function login(data) { | ||
return request({ | ||
url: '/api/authentication/login', | ||
method: 'post', | ||
data | ||
}) | ||
} | ||
|
||
// 登出 | ||
export function logout() { | ||
return request({ | ||
url: '/api/authentication/logout', | ||
method: 'get' | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useEffect } from "react" | ||
import { Spin } from "antd" | ||
// import NProgress from "nprogress" // progress bar | ||
// import "nprogress/nprogress.css" // progress bar style | ||
|
||
// NProgress.configure({ showSpinner: false }) // NProgress Configuration | ||
|
||
const Loading = () => { | ||
useEffect(() => { | ||
// NProgress.start() | ||
return () => { | ||
// NProgress.done() | ||
} | ||
}, []) | ||
|
||
return ( | ||
<div className="app-container"> | ||
<Spin /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Loading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Loadable from 'react-loadable' | ||
import loading from '@/components/Loading' | ||
|
||
const Home = Loadable({ loader: () => import(/*webpackChunkName:'Home'*/'@/pages/home'), loading }) | ||
const Error404 = Loadable({ loader: () => import(/*webpackChunkName:'Error404'*/'@/pages/404'), loading }) | ||
|
||
export default [ | ||
{ path: "/home", component: Home, roles: ["admin"] }, | ||
{ path: "/404", component: Error404 } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { Component } from 'react' | ||
import { Redirect, withRouter, Route, Switch } from "react-router-dom" | ||
import { connect } from 'react-redux' | ||
import routeList from "@/config/routeMap" | ||
|
||
// class Content extends Component { | ||
|
||
// render() { | ||
// return <div></div> | ||
// } | ||
// } | ||
|
||
const LayoutContent = props => { | ||
const { role, location } = props | ||
// const { pathname } = location | ||
// const handleFilter = (route) => { | ||
// // 过滤没有权限的页面 | ||
// return role === "admin" || !route.roles || route.roles.includes(role) | ||
// } | ||
return ( | ||
<Switch location={location}> | ||
<Redirect exact from="/" to="/home" /> | ||
{ | ||
routeList.map(route => { | ||
return ( | ||
// handleFilter | ||
<Route component={route.component} key={route.path} path={route.path} /> | ||
) | ||
}) | ||
} | ||
</Switch> | ||
) | ||
} | ||
|
||
export default connect()(LayoutContent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, { Component } from 'react' | ||
import{ loginOut } from '@/store/actions/user' | ||
import { connect } from 'react-redux' | ||
class User extends Component { | ||
|
||
out = () => { | ||
this.props.loginOut() | ||
} | ||
|
||
render() { | ||
return <button className="user" onClick={this.out}>退出登录</button> | ||
} | ||
} | ||
|
||
export default connect(null, { loginOut })(User) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { Component } from 'react' | ||
import { Link } from 'react-router-dom' | ||
import { connect } from 'react-redux' | ||
import User from './components/User' | ||
import './index.scss' | ||
|
||
const linkList = [ | ||
{ to: "/home", name: 'Home' }, | ||
{ to: "/404", name: '404' } | ||
] | ||
|
||
class Header extends Component { | ||
render() { | ||
return ( | ||
<div className="header"> | ||
{ | ||
linkList.map(link => { | ||
return <Link key={link.name} to={link.to} >{link.name}</Link> | ||
}) | ||
} | ||
<User></User> | ||
</div> | ||
) | ||
} | ||
} | ||
export default connect()(Header) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.header { | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
background-color: pink; | ||
height: 40px; | ||
a { | ||
width: 100px; | ||
text-align: center; | ||
background-color: yellow; | ||
} | ||
.user { | ||
position: absolute; | ||
right: 10px; | ||
cursor: pointer; | ||
// background-color: green; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
import { loginOut } from '../../../store/actions/user' | ||
// import { loginOut } from '../../store/actions/user' | ||
|
||
class Narbar extends Component { | ||
loginOut = () => { | ||
this.props.loginOut() | ||
} | ||
|
||
render() { | ||
return <button onClick={this.loginOut}>退出登录</button> | ||
} | ||
|
||
} | ||
export default connect( | ||
state => ({ | ||
userInfo: state.userInfo | ||
}), | ||
{ | ||
loginOut | ||
} | ||
)(Narbar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { Component } from 'react' | ||
import Navbar from './components/Navbar' | ||
import Header from './Header' | ||
import Content from './Content' | ||
// import RouterMap from '../router' | ||
|
||
class index extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<Header /> | ||
<Content/> | ||
{/* <Navbar /> */} | ||
{/* <RouterMap/> */} | ||
</div> | ||
) | ||
} | ||
} | ||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
import { loginOut } from '../../redux/acitons/login' | ||
|
||
class Home extends Component { | ||
|
||
loginOut = () => { | ||
this.props.loginOut() | ||
} | ||
|
||
render() { | ||
return <button onClick={this.loginOut}>退出登录</button> | ||
return <div>home</div> | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ({ | ||
userInfo: state.userInfo | ||
}), | ||
{ | ||
loginOut | ||
} | ||
)(Home) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.