diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 0f70e7c..175df35 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -13,8 +13,6 @@ function RouteMap(props: any) { return ( {routes.map((route, index) => { - console.log(route.path, route.exact) - const { exact = false } = route if (route.redirect) { return ( @@ -26,7 +24,7 @@ function RouteMap(props: any) { if (route.component) { return ( - {route.children && } + {route.children && } ) } @@ -40,15 +38,11 @@ export default function () { return ( - {/* */} { - return ( - - ) + return }} > - {/* */} ) } diff --git a/src/assets/style/common.scss b/src/assets/style/common.scss index 400203d..fca9333 100644 --- a/src/assets/style/common.scss +++ b/src/assets/style/common.scss @@ -8,13 +8,13 @@ textarea { font: 12px/1.5 tahoma, arial, "Hiragino Sans GB", "\5b8b\4f53", sans-serif; } -// body{ -// background-image: url("@/assets/images/0.jpg"); -// background-attachment: fixed; -// background-position: center top 36px; -// background-repeat: no-repeat; -// background-size: cover; -// } +body{ + background-image: url("@/assets/images/0.jpg"); + background-attachment: fixed; + background-position: center top 36px; + background-repeat: no-repeat; + background-size: cover; +} a { // color: initial; display: inline-block; diff --git a/src/plugins/pageHoc/index.tsx b/src/plugins/pageHoc/index.tsx index 02ec7f5..0f2753b 100644 --- a/src/plugins/pageHoc/index.tsx +++ b/src/plugins/pageHoc/index.tsx @@ -1,28 +1,27 @@ -import React, { Component } from "react"; +import React, { Component } from "react" -export const pageList:any[] = []; +export const pageList: any[] = [] export default function (options: any) { return (WrappedComponent: any) => { const { path, // 页面路径 - } = options; + } = options class HOC extends React.Component { constructor(props: any) { - super(props); + super(props) } componentDidMount() {} componentWillUnmount() {} render() { - return ; + return } } - pageList.push([{ ...options, Component: HOC }]); - console.log(pageList); - return HOC; - }; + pageList.push([{ ...options, Component: HOC }]) + return HOC + } } diff --git a/src/route.tsx b/src/route.tsx index 49caaf0..c76e850 100644 --- a/src/route.tsx +++ b/src/route.tsx @@ -11,7 +11,6 @@ export default [ { path: "/about", component: About, - exact: false, meta: { auth: true, }, @@ -19,14 +18,12 @@ export default [ { path: "/about/test", component: Test, - exact: false, }, ], }, { path: "/home", component: Home, - exact: true, meta: { auth: false, }, diff --git a/src/views/Home/Header.tsx b/src/views/Home/Header.tsx index 6fb1180..0c31790 100644 --- a/src/views/Home/Header.tsx +++ b/src/views/Home/Header.tsx @@ -1,28 +1,28 @@ -import React, {useState} from "react"; +import React, { useState } from "react" export default () => { - const title = "秦时明月"; + const title = "美女管理后台" const [leftMenuList, setLeftMenuList] = useState([ - {title: "首页", path: "/"}, - {title: "角色", children: [{title: "月儿", path: "/about"}]}, - ]); + { title: "首页", path: "/" }, + { title: "角色", children: [{ title: "月儿", path: "/about" }] }, + ]) const [rightMenuList, setRightMenuList] = useState([ { title: "登录/注册", - click: true + click: true, }, - ]); + ]) function onLeftClick(e: any, menu: any, allMenu: any) { if (menu.click || !menu.path) { - e.preventDefault(); + e.preventDefault() } } function onRightClick(e: any, menu: any, allMenu: any) { if (menu.click || !menu.path) { - e.preventDefault(); + e.preventDefault() } } @@ -30,65 +30,57 @@ export default () => {
-
- {title} -
+
{title}
- ); -}; + ) +} diff --git a/src/views/Home/index.tsx b/src/views/Home/index.tsx index 70fa1a9..c3b7f8c 100644 --- a/src/views/Home/index.tsx +++ b/src/views/Home/index.tsx @@ -1,13 +1,17 @@ -import {addTodo, removeTodo} from "@/store/action/todo"; -import PropTypes from 'prop-types' -import React, {FormEvent, useRef} from "react"; -import {connect} from "react-redux"; -import Header from "./Header"; +import { addTodo, removeTodo } from "@/store/action/todo" +import React, { FormEvent, useRef, useContext } from "react" +import { connect } from "react-redux" +import Header from "./Header" -function Home(props: any) { +export interface HomeProps { + add(text: string): void + todo: ITodo[] + remove(id: number): void +} - const {todo, add, remove} = props - const inputRef = useRef(null); +function Home(props: HomeProps) { + const { todo, add, remove } = props + const inputRef = useRef(null) function addOne(e: FormEvent) { e.preventDefault() @@ -24,14 +28,18 @@ function Home(props: any) {
-
addOne(e)}> - + addOne(e)}> +
- {todo - .map((v: ITodo) => { - return

remove(v.id)} key={v.id}>{v.text}{v.id}

; - })} + {todo.map((v: ITodo) => { + return ( +

remove(v.id)} key={v.id}> + {v.text} + {v.id} +

+ ) + })}
@@ -49,19 +57,9 @@ function Home(props: any) { ) } -Home.propTypes = { - todo: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.number.isRequired, - text: PropTypes.string.isRequired - }).isRequired).isRequired, - add: PropTypes.func.isRequired, - remove: PropTypes.func.isRequired -} - const mapStateToProps = (state: any) => { - console.log(state) return { - todo: state.todo + todo: state.todo, } } @@ -70,4 +68,4 @@ const mapDispatchToProps = (dispatch: any) => ({ remove: (id: string | number) => dispatch(removeTodo(id)), }) -export default connect(mapStateToProps, mapDispatchToProps)(Home); +export default connect(mapStateToProps, mapDispatchToProps)(Home)