This commit is contained in:
tangly1024
2023-06-23 15:56:59 +08:00
parent 5f29858c37
commit a1708605da
7 changed files with 39 additions and 25 deletions

View File

@@ -4,7 +4,6 @@ import { useRouter } from 'next/router'
import BLOG from '@/blog.config'
import { ALL_THEME, initDarkMode } from '@/themes/theme'
import NProgress from 'nprogress'
import LoadingCover from '@/components/LoadingCover'
import { getQueryVariable, isBrowser } from './utils'
const GlobalContext = createContext()
@@ -22,7 +21,7 @@ export function GlobalContextProvider({ children }) {
const [theme, setTheme] = useState(BLOG.THEME) // 默认博客主题
const [isDarkMode, updateDarkMode] = useState(BLOG.APPEARANCE === 'dark') // 默认深色模式
const [onLoading, setOnLoading] = useState(false) // 抓取文章数据
const [onReading, setOnReading] = useState(false) // 网页资源加载
// const [onReading, setOnReading] = useState(false) // 网页资源加载
useEffect(() => {
initLocale(lang, locale, updateLang, updateLocale)
@@ -34,7 +33,7 @@ export function GlobalContextProvider({ children }) {
// setOnReading(true)
}
// 监听页面元素加载完
setOnReading(false)
// setOnReading(false)
window.addEventListener('beforeunload', handleBeforeUnload)
return () => {
window.removeEventListener('beforeunload', handleBeforeUnload)
@@ -88,10 +87,8 @@ export function GlobalContextProvider({ children }) {
updateDarkMode,
theme,
setTheme,
switchTheme,
setOnReading
switchTheme
}}>
<LoadingCover onReading={onReading} setOnReading={setOnReading}/>
{children}
</GlobalContext.Provider>
)