动态主题初版本完成

This commit is contained in:
tangly1024
2022-03-09 17:28:47 +08:00
parent 69422fff7f
commit 24007eed1a
17 changed files with 58 additions and 49 deletions

View File

@@ -3,7 +3,6 @@ import { useContext, createContext, useState } from 'react'
import Router from 'next/router'
import { initDarkMode } from './theme'
import BLOG from '@/blog.config'
import * as ThemeMap from '@/themes'
const GlobalContext = createContext()
let hasInit = false
@@ -18,8 +17,6 @@ export function GlobalContextProvider ({ children }) {
const [isDarkMode, updateDarkMode] = useState(false)
const [onLoading, changeLoadingState] = useState(false)
const [theme, setTheme] = useState(BLOG.THEME)
console.log('ThemeMap', ThemeMap)
const ThemeComponents = ThemeMap[theme]
Router.events.on('routeChangeStart', (...args) => {
changeLoadingState(true)
@@ -39,7 +36,7 @@ export function GlobalContextProvider ({ children }) {
}, 100)
return (
<GlobalContext.Provider value={{ onLoading, locale, isDarkMode, updateDarkMode, theme, setTheme, ThemeComponents }}>
<GlobalContext.Provider value={{ onLoading, locale, isDarkMode, updateDarkMode, theme, setTheme }}>
{children}
</GlobalContext.Provider>
)