import electron from "@/plugins/electron" import { addTodo, removeTodo } from "@/store/action/todo" import { Button, ButtonGroup, ControlGroup, FormGroup, HotkeysProvider, InputGroup } from "@blueprintjs/core" import { Cell, Column, Table2 } from "@blueprintjs/table" import cs from "classnames" import _ from "lodash" import React, { useEffect, useRef, useState } from "react" import { connect } from "react-redux" import Dialog from "./Dialog" import style from "./index.module.scss" import useLocation from "./useLocation" export interface HomeProps { add(text: string): void todo: ITodo[] remove(id: number): void } let keyGen = 0 function Home(props: HomeProps) { const [isOpen, setIsOpen] = useState(false) const keyRef = useRef(null) function delItem() { let key = keyRef.current?.value if (key) { let index = _.findIndex(clockList, { key: +key }) if (index != -1) { var list = [...clockList] list.splice(index, 1) setClockList(list) keyRef.current!.value = "" } } } const { save, get } = useLocation() const [clockList, setClockList] = useState[]>([]) const keyList = _.map(clockList, "key") const titleList = _.map(clockList, "title") const timeList = _.map(clockList, "time") const descList = _.map(clockList, "desc") function onConfrim(title: string, time: string, desc: string) { if (title && time) { const value = { key: ++keyGen, title: title, time: time, desc: desc, } setClockList([...clockList, value]) setIsOpen(false) } } useEffect(() => { ;(async () => { let list = await electron.ipcRenderer.invoke("@func:clock:getData") if (list) { setClockList(list) const keyList = _.map(list, "key") if (keyList.length) { keyGen = Math.max(...keyList) } } })() }, []) useEffect(() => { electron.ipcRenderer.send("@func:clock:saveData", clockList) }, [clockList]) return (
闹钟列表
Month Savings
Sum $180
January $100
February $80
{/* {keyList[index]}}> {titleList[index]}}> {timeList[index]}}> {descList[index]}}> */}
) } const mapStateToProps = (state: any) => { return { todo: state.todo, } } const mapDispatchToProps = (dispatch: any) => ({ add: (text: string) => dispatch(addTodo(text)), remove: (id: string | number) => dispatch(removeTodo(id)), }) export default connect(mapStateToProps, mapDispatchToProps)(Home)