diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx
index 8e5e63e..266f2a9 100644
--- a/src/components/Layout/index.tsx
+++ b/src/components/Layout/index.tsx
@@ -1,5 +1,5 @@
'use client';
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import { Layout, Menu, theme, Avatar, Dropdown, ConfigProvider, Badge, Popover, type MenuProps } from 'antd';
import getNavList from './menu';
import { useRouter } from 'next/navigation';
@@ -22,6 +22,10 @@ interface IProps {
defaultOpen?: string[]
}
+const onLogout = () => {
+ localStorage.removeItem("isDarkTheme")
+}
+
const items: MenuProps['items'] = [
{
key: '1',
@@ -42,7 +46,7 @@ const items: MenuProps['items'] = [
{
key: '3',
label: (
-
+
退出登录
),
@@ -65,13 +69,20 @@ const CommonLayout: React.FC = ({ children, curActive, defaultOpen = ['/
const [curTheme, setCurTheme] = useState(false);
const toggleTheme = () => {
- setCurTheme(prev => !prev);
+ const _curTheme = !curTheme;
+ setCurTheme(_curTheme);
+ localStorage.setItem('isDarkTheme', _curTheme ? 'true' : '');
}
const handleSelect = (row: {key: string}) => {
router.push(row.key)
}
+ useEffect(() => {
+ const isDark = !!localStorage.getItem("isDarkTheme");
+ setCurTheme(isDark);
+ }, []);
+
return (