12 changed files with 274 additions and 837 deletions
File diff suppressed because it is too large
@ -1,3 +0,0 @@ |
|||
.Home { |
|||
background-color: transparent; |
|||
} |
@ -1,34 +1,33 @@ |
|||
import { addTodo, removeTodo } from "@/store/action/todo" |
|||
import React from "react" |
|||
import { connect } from "react-redux" |
|||
import { connect, useStore } from "react-redux" |
|||
import style from "./index.module.scss" |
|||
import { Button } from "@chakra-ui/react" |
|||
import { Icon } from "@blueprintjs/core" |
|||
|
|||
export interface HomeProps { |
|||
add(text: string): void |
|||
|
|||
todo: ITodo[] |
|||
|
|||
remove(id: number): void |
|||
} |
|||
|
|||
function Home(props: HomeProps) { |
|||
const tabs = [ |
|||
{icon: "globe", title:"添加闹钟"} |
|||
] |
|||
return ( |
|||
<div className={style.Home}> |
|||
<Button>asd</Button> |
|||
</div> |
|||
<div>sada</div> |
|||
) |
|||
} |
|||
|
|||
const mapStateToProps = (state: any) => { |
|||
return { |
|||
todo: state.todo |
|||
todo: state.todo, |
|||
} |
|||
} |
|||
|
|||
const mapDispatchToProps = (dispatch: any) => ({ |
|||
add: (text: string) => dispatch(addTodo(text)), |
|||
remove: (id: string | number) => dispatch(removeTodo(id)) |
|||
remove: (id: string | number) => dispatch(removeTodo(id)), |
|||
}) |
|||
|
|||
export default connect(mapStateToProps, mapDispatchToProps)(Home) |
|||
|
@ -0,0 +1,33 @@ |
|||
.Layout { |
|||
height: 100vh; |
|||
.left { |
|||
position: fixed; |
|||
left: 0; |
|||
top: 0; |
|||
bottom: 0; |
|||
background-color: #2c2c2c; |
|||
width: 45px; |
|||
display: flex; |
|||
flex-direction: column; |
|||
overflow: hidden; |
|||
.leftList,.leftListBottom { |
|||
width: 100%; |
|||
.leftItem { |
|||
text-align: center; |
|||
padding: 10px 0; |
|||
color: #808080; |
|||
cursor: pointer; |
|||
&:hover { |
|||
color: #f8ffff; |
|||
} |
|||
} |
|||
} |
|||
.leftList{ |
|||
flex-grow: 1; |
|||
flex-shrink: 0; |
|||
} |
|||
} |
|||
.right{ |
|||
margin-left: 45px; |
|||
} |
|||
} |
@ -1,16 +1,85 @@ |
|||
import React, { ReactElement } from "react" |
|||
import style from "./index.module.scss" |
|||
import { useLocation } from "react-router-dom" |
|||
import { Icon } from "@blueprintjs/core" |
|||
import route from "@render/route" |
|||
|
|||
// interface IProps {
|
|||
// render(): ReactElement
|
|||
// }
|
|||
|
|||
function foundRoute(route:any, name:string, arrIndex?: number[]):any{ |
|||
if(!arrIndex){ |
|||
arrIndex = [] |
|||
} |
|||
for (let i = 0; i < route.length; i++) { |
|||
const element = route[i]; |
|||
if(element.root){ |
|||
arrIndex = [] |
|||
} |
|||
arrIndex.push(i); |
|||
let lena = element.path.split("/").length |
|||
let lenb =name.split("/").length |
|||
console.log(element.path, name,lena,lenb, element.path == name && lena==lenb); |
|||
if(element.path == name && lena==lenb){ |
|||
return arrIndex |
|||
} else if(element.children){ |
|||
let a = foundRoute(element.children, name, arrIndex); |
|||
if(a){ |
|||
return a |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
export default function (props: any) { |
|||
const {pathname} = useLocation() |
|||
|
|||
console.log(pathname); |
|||
console.log(route); |
|||
let oroute = JSON.parse(JSON.stringify(route)) |
|||
let index = foundRoute(route, pathname) |
|||
console.log(index); |
|||
let isLayout = true; |
|||
if(index&&index.length){ |
|||
let res = oroute[index[0]]; |
|||
let cur = res; |
|||
for (let i = 1; i < index.length; i++) { |
|||
const element = index[i]; |
|||
cur.children = [cur.children[element]] |
|||
cur = cur.children[element] |
|||
} |
|||
if(cur){ |
|||
cur.children = []; |
|||
} |
|||
console.log(cur); |
|||
if(cur.layout!=undefined){ |
|||
isLayout = !!cur.layout |
|||
} |
|||
console.log(res); |
|||
} |
|||
|
|||
return ( |
|||
<div> |
|||
<div className="content"> |
|||
isLayout?( |
|||
<div className={style.Layout}> |
|||
<div className={style.left}> |
|||
<div className={style.leftList}> |
|||
<div className={style.leftItem} title={"添加闹钟"}> |
|||
<Icon icon="time" size={20}/> |
|||
<div>闹钟</div> |
|||
</div> |
|||
</div> |
|||
<div className={style.leftListBottom}> |
|||
<div className={style.leftItem} title={"设置"}> |
|||
<Icon icon="settings" size={20} /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div className={style.right}> |
|||
<props.render></props.render> |
|||
</div> |
|||
<div>sad</div> |
|||
</div> |
|||
):(<props.render></props.render>) |
|||
) |
|||
} |
|||
|
Loading…
Reference in new issue