San3yuan | 03ab064 | 2025-04-29 18:00:25 +0800 | [diff] [blame^] | 1 | import React from "react"; |
| 2 | import { Outlet } from "react-router"; |
| 3 | import { useEffect, useState } from "react"; |
| 4 | import { |
| 5 | SearchOutlined, |
| 6 | FontSizeOutlined, |
| 7 | MessageOutlined, |
| 8 | SunOutlined, |
| 9 | MoonOutlined |
| 10 | } from "@ant-design/icons"; |
| 11 | import style from "./frame.module.css"; |
| 12 | import logo from "&/assets/logo.png"; |
| 13 | import { useAppDispatch } from "@/hooks/store"; |
| 14 | import { useSelector } from "react-redux"; |
| 15 | const Frame:React.FC = () => { |
| 16 | |
| 17 | const dispatch = useAppDispatch(); |
| 18 | |
| 19 | const showSearch = useSelector((state: any) => state.setting.showSearch); |
| 20 | const theme= useSelector((state: any) => state.setting.theme); |
| 21 | const toggleSearch = () => { |
| 22 | dispatch({ type: "setting/toggleSearch" }); |
| 23 | } |
| 24 | |
| 25 | const toggleFontSize = () => { |
| 26 | dispatch({ type: "setting/toggleFontSize" }); |
| 27 | }; |
| 28 | |
| 29 | const toggleTheme = () => { |
| 30 | dispatch({ type: "setting/toggleTheme" }); |
| 31 | }; |
| 32 | |
| 33 | |
| 34 | return ( |
| 35 | <div style={{ display: 'block', height: '100vh' }}> |
| 36 | <header className={style.header}> |
| 37 | <img className={style.logo} src={logo} alt="website logo"></img> |
| 38 | {showSearch && (<input className={style.searchInput} placeholder="输入关键词进行搜索"/>)} |
| 39 | <div className={style.toollist}> |
| 40 | <SearchOutlined onClick={toggleSearch}/> |
| 41 | <FontSizeOutlined onClick={toggleFontSize}/> |
| 42 | <MessageOutlined /> |
| 43 | {theme === 'dark' ? <MoonOutlined onClick={toggleTheme}/> : <SunOutlined onClick={toggleTheme}/>} |
| 44 | </div> |
| 45 | </header> |
| 46 | <div className={style.container}> |
| 47 | <Outlet/> |
| 48 | </div> |
| 49 | |
| 50 | |
| 51 | </div> |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | export default Frame; |