blob: c0c2e0ecd36144860e28d84126932e63775fcfc8 [file] [log] [blame]
San3yuan03ab0642025-04-29 18:00:25 +08001import React from "react";
2import { Outlet } from "react-router";
3import { useEffect, useState } from "react";
4import {
5 SearchOutlined,
6 FontSizeOutlined,
7 MessageOutlined,
8 SunOutlined,
9 MoonOutlined
10 } from "@ant-design/icons";
11import style from "./frame.module.css";
12import logo from "&/assets/logo.png";
13import { useAppDispatch } from "@/hooks/store";
14import { useSelector } from "react-redux";
15const 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
55export default Frame;