blob: f41e53f9e44496129e9a3f51c00142645ae13d8c [file] [log] [blame]
San3yuana2ee30b2025-06-05 21:20:17 +08001import React, { use } from "react";
San3yuan03ab0642025-04-29 18:00:25 +08002import { 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";
San3yuana2ee30b2025-06-05 21:20:17 +080015
16import { checkAndRefreshToken } from "@/utils/jwt";
San3yuan03ab0642025-04-29 18:00:25 +080017const Frame:React.FC = () => {
18
San3yuana2ee30b2025-06-05 21:20:17 +080019 useEffect(() => {
20 checkAndRefreshToken();
21 }, []);
San3yuan03ab0642025-04-29 18:00:25 +080022 const dispatch = useAppDispatch();
23
24 const showSearch = useSelector((state: any) => state.setting.showSearch);
25 const theme= useSelector((state: any) => state.setting.theme);
26 const toggleSearch = () => {
27 dispatch({ type: "setting/toggleSearch" });
28 }
29
30 const toggleFontSize = () => {
31 dispatch({ type: "setting/toggleFontSize" });
32 };
33
34 const toggleTheme = () => {
35 dispatch({ type: "setting/toggleTheme" });
36 };
37
38
39 return (
40 <div style={{ display: 'block', height: '100vh' }}>
41 <header className={style.header}>
42 <img className={style.logo} src={logo} alt="website logo"></img>
43 {showSearch && (<input className={style.searchInput} placeholder="输入关键词进行搜索"/>)}
44 <div className={style.toollist}>
45 <SearchOutlined onClick={toggleSearch}/>
46 <FontSizeOutlined onClick={toggleFontSize}/>
47 <MessageOutlined />
48 {theme === 'dark' ? <MoonOutlined onClick={toggleTheme}/> : <SunOutlined onClick={toggleTheme}/>}
49 </div>
50 </header>
51 <div className={style.container}>
52 <Outlet/>
53 </div>
54
55
56 </div>
57 );
58}
59
60export default Frame;