blank-theme-with-daisy

This commit is contained in:
tangly1024
2023-06-30 23:24:55 +08:00
parent 8103e23aac
commit aac5eac0fc
18 changed files with 326 additions and 19 deletions

View File

@@ -2,7 +2,7 @@ import { generateLocaleDict, initLocale } from './lang'
import { createContext, useContext, useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import BLOG from '@/blog.config'
import { ALL_THEME, initDarkMode } from '@/themes/theme'
import { THEMES, initDarkMode } from '@/themes/theme'
import NProgress from 'nprogress'
import { getQueryVariable, isBrowser } from './utils'
@@ -69,9 +69,9 @@ export function GlobalContextProvider({ children }) {
// 切换主题
function switchTheme() {
const currentIndex = ALL_THEME.indexOf(theme)
const newIndex = currentIndex < ALL_THEME.length - 1 ? currentIndex + 1 : 0
const newTheme = ALL_THEME[newIndex]
const currentIndex = THEMES.indexOf(theme)
const newIndex = currentIndex < THEMES.length - 1 ? currentIndex + 1 : 0
const newTheme = THEMES[newIndex]
const query = { ...router.query, theme: newTheme }
router.push({ pathname: router.pathname, query })
return newTheme