mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 19:46:38 +08:00
优化
优化
This commit is contained in:
@@ -3,12 +3,13 @@ import { useCallback, useEffect, useState } from 'react'
|
||||
export type ThemeMode = 'light' | 'dark' | 'system'
|
||||
export type ResolvedTheme = 'light' | 'dark'
|
||||
|
||||
const THEME_STORAGE_KEY = 'mediastationgo.theme'
|
||||
const THEME_STORAGE_KEY = 'mmtl.theme'
|
||||
const THEME_LEGACY_STORAGE_KEY = 'mediastationgo.theme'
|
||||
const DARK_QUERY = '(prefers-color-scheme: dark)'
|
||||
|
||||
function readStoredTheme(): ThemeMode {
|
||||
if (typeof window === 'undefined') return 'system'
|
||||
const value = window.localStorage.getItem(THEME_STORAGE_KEY)
|
||||
const value = window.localStorage.getItem(THEME_STORAGE_KEY) || window.localStorage.getItem(THEME_LEGACY_STORAGE_KEY)
|
||||
return value === 'light' || value === 'dark' || value === 'system' ? value : 'system'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user