mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-06 07:26:45 +00:00
feature:
语言本地化完善; 夜间模式完善; 封装版权声明; 侧边栏sticky优化
This commit is contained in:
@@ -88,33 +88,31 @@ const initTheme = (theme, changeTheme) => {
|
||||
const date = new Date()
|
||||
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
const useDark = prefersDarkMode || (date.getHours() >= 18 || date.getHours() < 6)
|
||||
const htmlElement = document.getElementsByTagName('html')
|
||||
|
||||
if (useDark) {
|
||||
changeTheme('dark')
|
||||
saveTheme('dark')
|
||||
htmlElement.classList.remove('light')
|
||||
htmlElement.classList.add('dark')
|
||||
} else {
|
||||
changeTheme('light')
|
||||
saveTheme('light')
|
||||
htmlElement.classList.remove('dark')
|
||||
htmlElement.classList.add('light')
|
||||
}
|
||||
}
|
||||
const baseLayoutClass = document.getElementById('wrapper')?.classList
|
||||
if (baseLayoutClass && !baseLayoutClass.contains(theme)) {
|
||||
baseLayoutClass.add(theme)
|
||||
}
|
||||
}
|
||||
|
||||
export function handleRouteChange (url) {
|
||||
console.log('路由变化', url)
|
||||
initGoogleAdsense()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化谷歌广告
|
||||
*/
|
||||
// let activeAdsCount = 0
|
||||
function initGoogleAdsense () {
|
||||
const ads = document.getElementsByClassName('adsbygoogle').length
|
||||
// const newAdsCount = ads - activeAdsCount
|
||||
// console.log(`Start: 总广告${ads}, 已激活${activeAdsCount} 新广告${newAdsCount}`)
|
||||
const newAdsCount = ads
|
||||
if (newAdsCount > 0) {
|
||||
for (let i = 0; i <= newAdsCount; i++) {
|
||||
|
||||
Reference in New Issue
Block a user