mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-08-12 11:50:13 +08:00
feat: improve web mode notification (#309)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { useConfig } from './use-config.mjs'
|
||||
import { useWindowTheme } from './use-window-theme.mjs'
|
||||
|
||||
export function useTheme() {
|
||||
const config = useConfig()
|
||||
const theme = useWindowTheme()
|
||||
return [config.themeMode === 'auto' ? theme : config.themeMode, config]
|
||||
}
|
||||
@@ -2,8 +2,10 @@ import { useEffect, useState } from 'react'
|
||||
|
||||
export function useWindowTheme() {
|
||||
const [theme, setTheme] = useState(
|
||||
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
? 'dark'
|
||||
window.matchMedia
|
||||
? window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
? 'dark'
|
||||
: 'light'
|
||||
: 'light',
|
||||
)
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user