mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-18 15:09:34 +00:00
动态页面展示;
This commit is contained in:
@@ -3,6 +3,7 @@ import { useContext, createContext, useState } from 'react'
|
||||
import Router from 'next/router'
|
||||
import { initDarkMode } from './theme'
|
||||
import BLOG from '@/blog.config'
|
||||
import { ThemeMap } from '@/themes'
|
||||
const GlobalContext = createContext()
|
||||
let hasInit = false
|
||||
|
||||
@@ -17,6 +18,8 @@ export function GlobalContextProvider ({ children }) {
|
||||
const [isDarkMode, updateDarkMode] = useState(false)
|
||||
const [onLoading, changeLoadingState] = useState(false)
|
||||
const [theme, setTheme] = useState(BLOG.THEME)
|
||||
const ThemeComponents = ThemeMap[theme]
|
||||
|
||||
Router.events.on('routeChangeStart', (...args) => {
|
||||
changeLoadingState(true)
|
||||
})
|
||||
@@ -35,7 +38,7 @@ export function GlobalContextProvider ({ children }) {
|
||||
}, 100)
|
||||
|
||||
return (
|
||||
<GlobalContext.Provider value={{ onLoading, locale, isDarkMode, updateDarkMode, theme, setTheme }}>
|
||||
<GlobalContext.Provider value={{ onLoading, locale, isDarkMode, updateDarkMode, theme, setTheme, ThemeComponents }}>
|
||||
{children}
|
||||
</GlobalContext.Provider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user