diff --git a/package.json b/package.json index 1b01048..75bf897 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "react-dom": "^18.2.0", "react-easy-sort": "^1.5.3", "react-grid-layout": "1.4.2", + "react-icons": "^4.12.0", "react-resizable": "^3.0.5", "react-router": "^6.15.0", "react-router-dom": "^6.15.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6d4ddd..3d4d08a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -142,6 +142,9 @@ dependencies: react-grid-layout: specifier: 1.4.2 version: 1.4.2(react-dom@18.2.0)(react@18.2.0) + react-icons: + specifier: ^4.12.0 + version: 4.12.0(react@18.2.0) react-resizable: specifier: ^3.0.5 version: 3.0.5(react-dom@18.2.0)(react@18.2.0) @@ -6932,6 +6935,14 @@ packages: resize-observer-polyfill: 1.5.1 dev: false + /react-icons@4.12.0(react@18.2.0): + resolution: {integrity: sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==} + peerDependencies: + react: '*' + dependencies: + react: 18.2.0 + dev: false + /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} dev: false diff --git a/src/client/App.tsx b/src/client/App.tsx index 20a1f22..7b03043 100644 --- a/src/client/App.tsx +++ b/src/client/App.tsx @@ -15,6 +15,9 @@ import { MonitorPage } from './pages/Monitor'; import { WebsitePage } from './pages/Website'; import { useGlobalConfig } from './hooks/useConfig'; import { useInjectWebsiteScript } from './hooks/useInjectWebsiteScript'; +import { ConfigProvider, theme } from 'antd'; +import { useGlobalStateStore } from './store/global'; +import clsx from 'clsx'; export const AppRoutes: React.FC = React.memo(() => { const { info } = useUserStore(); @@ -51,14 +54,24 @@ export const AppRoutes: React.FC = React.memo(() => { AppRoutes.displayName = 'AppRoutes'; export const App: React.FC = React.memo(() => { + const colorScheme = useGlobalStateStore((state) => state.colorScheme); + const algorithm = + colorScheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm; + return ( -
+
- - - + + + + + diff --git a/src/client/components/ColorSchemeSwitcher.tsx b/src/client/components/ColorSchemeSwitcher.tsx new file mode 100644 index 0000000..24c955f --- /dev/null +++ b/src/client/components/ColorSchemeSwitcher.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { useGlobalStateStore } from '../store/global'; +import { LuMoon, LuSun } from 'react-icons/lu'; +import { useEvent } from '../hooks/useEvent'; +import { Button } from 'antd'; + +export const ColorSchemeSwitcher: React.FC = React.memo(() => { + const colorScheme = useGlobalStateStore((state) => state.colorScheme); + const handleSwitchColorScheme = useEvent(() => { + useGlobalStateStore.setState({ + colorScheme: colorScheme === 'dark' ? 'light' : 'dark', + }); + }); + + return ( +