mirror of
https://gitee.com/dcren/cloud-native-app-initializer.git
synced 2026-08-25 19:06:31 +08:00
Project initial
This commit is contained in:
18
initializer-page/src/components/utils/Theme.js
Normal file
18
initializer-page/src/components/utils/Theme.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import {useState} from 'react'
|
||||
|
||||
function getTheme() {
|
||||
const isDarkConfig =
|
||||
window.matchMedia &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
|
||||
const theme = localStorage.getItem('springtheme')
|
||||
if (!theme) {
|
||||
return isDarkConfig ? 'dark' : 'light'
|
||||
}
|
||||
return theme
|
||||
}
|
||||
|
||||
export default function useTheme() {
|
||||
const [darkTheme] = useState(getTheme())
|
||||
return darkTheme
|
||||
}
|
||||
Reference in New Issue
Block a user