Closed BH6AOV closed 2 years ago
有点奇怪,感觉是切换监听事件没有被挂载到按钮上导致的,看控制台这里有一个 clarity.ms 的代码加载报错(但不确定是不是被我的什么拦截器规则误伤了),其他暂时没法发现什么,手动执行样式切换是可行的
可以先去掉这行(应该是站点统计代码?)试试,或是在 script 里看看加个 type="text/javascript"
看看能否解决问题?
我回去注释掉试一下,按理说应该没影响x,之前用老版本(指不用npm安装的那个)的时候啥问题没有(?)
type="text/javascript"
一直是存在的,刚刚试着注释掉之后重新生成也还是完全没有用:
site_analytics:
<!--Bing/Clarity Analytics--><script type="text/javascript">(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", "********");</script><!--End of Bing/Clarity Analytics-->
刚刚尝试了一下,将控制台里所有的报错项目都删掉了(除了cloudflare那个烦人的static),一样还是不能用的,怪诶
根据加载失败的内容来看,你应该是使用了 cloudflare cdn
同时在 对应域名-Apps
里安装了一些应用
```js
;window.CloudflareApps=window.CloudflareApps||{};CloudflareApps.siteId="3bf9f6cadf55be30dc8bd75986975e99";CloudflareApps.installs=CloudflareApps.installs||{};;(function(){'use strict'
CloudflareApps.internal=CloudflareApps.internal||{}
var errors=[]
CloudflareApps.internal.placementErrors=errors
var errorHashes={}
function noteError(options){var hash=options.selector+'::'+options.type+'::'+(options.installId||'')
if(errorHashes[hash]){return}
errorHashes[hash]=true
errors.push(options)}
var initializedSelectors={}
var currentInit=false
CloudflareApps.internal.markSelectors=function markSelectors(){if(!currentInit){check()
currentInit=true
setTimeout(function(){currentInit=false})}}
function check(){var installs=window.CloudflareApps.installs
for(var installId in installs){if(!installs.hasOwnProperty(installId)){continue}
var selectors=installs[installId].selectors
if(!selectors){continue}
for(var key in selectors){if(!selectors.hasOwnProperty(key)){continue}
var hash=installId+'::'+key
if(initializedSelectors[hash]){continue}
var els=document.querySelectorAll(selectors[key])
if(els&&els.length>1){noteError({type:'init:too-many',option:key,selector:selectors[key],installId:installId})
initializedSelectors[hash]=true
continue}else if(!els||!els.length){continue}
initializedSelectors[hash]=true
els[0].setAttribute('cfapps-selector',selectors[key])}}}
CloudflareApps.querySelector=function querySelector(selector){if(selector==='body'||selector==='head'){return document[selector]}
CloudflareApps.internal.markSelectors()
var els=document.querySelectorAll('[cfapps-selector="'+selector+'"]')
if(!els||!els.length){noteError({type:'select:not-found:by-attribute',selector:selector})
els=document.querySelectorAll(selector)
if(!els||!els.length){noteError({type:'select:not-found:by-query',selector:selector})
return null}else if(els.length>1){noteError({type:'select:too-many:by-query',selector:selector})}
return els[0]}
if(els.length>1){noteError({type:'select:too-many:by-attribute',selector:selector})}
return els[0]}}());(function(){'use strict'
var prevEls={}
CloudflareApps.createElement=function createElement(options,prevEl){options=options||{}
CloudflareApps.internal.markSelectors()
try{if(prevEl&&prevEl.parentNode){var replacedEl
if(prevEl.cfAppsElementId){replacedEl=prevEls[prevEl.cfAppsElementId]}
if(replacedEl){prevEl.parentNode.replaceChild(replacedEl,prevEl)
delete prevEls[prevEl.cfAppsElementId]}else{prevEl.parentNode.removeChild(prevEl)}}
var element=document.createElement('cloudflare-app')
var container
if(options.pages&&options.pages.URLPatterns&&!CloudflareApps.matchPage(options.pages.URLPatterns)){return element}
try{container=CloudflareApps.querySelector(options.selector)}catch(e){}
if(!container){return element}
if(!container.parentNode&&(options.method==='after'||options.method==='before'||options.method==='replace')){return element}
if(container===document.body){if(options.method==='after'){options.method='append'}else if(options.method==='before'){options.method='prepend'}}
switch(options.method){case'prepend':if(container.firstChild){container.insertBefore(element,container.firstChild)
break}
case'append':container.appendChild(element)
break
case'after':if(container.nextSibling){container.parentNode.insertBefore(element,container.nextSibling)}else{container.parentNode.appendChild(element)}
break
case'before':container.parentNode.insertBefore(element,container)
break
case'replace':try{var id=element.cfAppsElementId=Math.random().toString(36)
prevEls[id]=container}catch(e){}
container.parentNode.replaceChild(element,container)}
return element}catch(e){if(typeof console!=='undefined'&&typeof console.error!=='undefined'){console.error('Error creating Cloudflare Apps element',e)}}}}());(function(){'use strict'
CloudflareApps.matchPage=function matchPage(patterns){if(!patterns||!patterns.length){return true}
var loc=document.location.host+document.location.pathname
if(window.CloudflareApps&&CloudflareApps.proxy&&CloudflareApps.proxy.originalURL){var url=CloudflareApps.proxy.originalURL.parsed
loc=url.host+url.path}
for(var i=0;i
可以尝试去cloudflare那边暂时停用cdn功能检查一下
根据加载失败的内容来看,你应该是使用了
cloudflare cdn
同时在对应域名-Apps
里安装了一些应用/cdn-cgi/apps/head/o8VSJLPlJ630VzpFGAYxShTLMQY.js
```js ;window.CloudflareApps=window.CloudflareApps||{};CloudflareApps.siteId="3bf9f6cadf55be30dc8bd75986975e99";CloudflareApps.installs=CloudflareApps.installs||{};;(function(){'use strict' CloudflareApps.internal=CloudflareApps.internal||{} var errors=[] CloudflareApps.internal.placementErrors=errors var errorHashes={} function noteError(options){var hash=options.selector+'::'+options.type+'::'+(options.installId||'') if(errorHashes[hash]){return} errorHashes[hash]=true errors.push(options)} var initializedSelectors={} var currentInit=false CloudflareApps.internal.markSelectors=function markSelectors(){if(!currentInit){check() currentInit=true setTimeout(function(){currentInit=false})}} function check(){var installs=window.CloudflareApps.installs for(var installId in installs){if(!installs.hasOwnProperty(installId)){continue} var selectors=installs[installId].selectors if(!selectors){continue} for(var key in selectors){if(!selectors.hasOwnProperty(key)){continue} var hash=installId+'::'+key if(initializedSelectors[hash]){continue} var els=document.querySelectorAll(selectors[key]) if(els&&els.length>1){noteError({type:'init:too-many',option:key,selector:selectors[key],installId:installId}) initializedSelectors[hash]=true continue}else if(!els||!els.length){continue} initializedSelectors[hash]=true els[0].setAttribute('cfapps-selector',selectors[key])}}} CloudflareApps.querySelector=function querySelector(selector){if(selector==='body'||selector==='head'){return document[selector]} CloudflareApps.internal.markSelectors() var els=document.querySelectorAll('[cfapps-selector="'+selector+'"]') if(!els||!els.length){noteError({type:'select:not-found:by-attribute',selector:selector}) els=document.querySelectorAll(selector) if(!els||!els.length){noteError({type:'select:not-found:by-query',selector:selector}) return null}else if(els.length>1){noteError({type:'select:too-many:by-query',selector:selector})} return els[0]} if(els.length>1){noteError({type:'select:too-many:by-attribute',selector:selector})} return els[0]}}());(function(){'use strict' var prevEls={} CloudflareApps.createElement=function createElement(options,prevEl){options=options||{} CloudflareApps.internal.markSelectors() try{if(prevEl&&prevEl.parentNode){var replacedEl if(prevEl.cfAppsElementId){replacedEl=prevEls[prevEl.cfAppsElementId]} if(replacedEl){prevEl.parentNode.replaceChild(replacedEl,prevEl) delete prevEls[prevEl.cfAppsElementId]}else{prevEl.parentNode.removeChild(prevEl)}} var element=document.createElement('cloudflare-app') var container if(options.pages&&options.pages.URLPatterns&&!CloudflareApps.matchPage(options.pages.URLPatterns)){return element} try{container=CloudflareApps.querySelector(options.selector)}catch(e){} if(!container){return element} if(!container.parentNode&&(options.method==='after'||options.method==='before'||options.method==='replace')){return element} if(container===document.body){if(options.method==='after'){options.method='append'}else if(options.method==='before'){options.method='prepend'}} switch(options.method){case'prepend':if(container.firstChild){container.insertBefore(element,container.firstChild) break} case'append':container.appendChild(element) break case'after':if(container.nextSibling){container.parentNode.insertBefore(element,container.nextSibling)}else{container.parentNode.appendChild(element)} break case'before':container.parentNode.insertBefore(element,container) break case'replace':try{var id=element.cfAppsElementId=Math.random().toString(36) prevEls[id]=container}catch(e){} container.parentNode.replaceChild(element,container)} return element}catch(e){if(typeof console!=='undefined'&&typeof console.error!=='undefined'){console.error('Error creating Cloudflare Apps element',e)}}}}());(function(){'use strict' CloudflareApps.matchPage=function matchPage(patterns){if(!patterns||!patterns.length){return true} var loc=document.location.host+document.location.pathname if(window.CloudflareApps&&CloudflareApps.proxy&&CloudflareApps.proxy.originalURL){var url=CloudflareApps.proxy.originalURL.parsed loc=url.host+url.path} for(var i=0;i
可以尝试去cloudflare那边暂时停用cdn功能检查一下
感谢,我去尝试一下
根据加载失败的内容来看,你应该是使用了
cloudflare cdn
同时在对应域名-Apps
里安装了一些应用/cdn-cgi/apps/head/o8VSJLPlJ630VzpFGAYxShTLMQY.js
```js ;window.CloudflareApps=window.CloudflareApps||{};CloudflareApps.siteId="3bf9f6cadf55be30dc8bd75986975e99";CloudflareApps.installs=CloudflareApps.installs||{};;(function(){'use strict' CloudflareApps.internal=CloudflareApps.internal||{} var errors=[] CloudflareApps.internal.placementErrors=errors var errorHashes={} function noteError(options){var hash=options.selector+'::'+options.type+'::'+(options.installId||'') if(errorHashes[hash]){return} errorHashes[hash]=true errors.push(options)} var initializedSelectors={} var currentInit=false CloudflareApps.internal.markSelectors=function markSelectors(){if(!currentInit){check() currentInit=true setTimeout(function(){currentInit=false})}} function check(){var installs=window.CloudflareApps.installs for(var installId in installs){if(!installs.hasOwnProperty(installId)){continue} var selectors=installs[installId].selectors if(!selectors){continue} for(var key in selectors){if(!selectors.hasOwnProperty(key)){continue} var hash=installId+'::'+key if(initializedSelectors[hash]){continue} var els=document.querySelectorAll(selectors[key]) if(els&&els.length>1){noteError({type:'init:too-many',option:key,selector:selectors[key],installId:installId}) initializedSelectors[hash]=true continue}else if(!els||!els.length){continue} initializedSelectors[hash]=true els[0].setAttribute('cfapps-selector',selectors[key])}}} CloudflareApps.querySelector=function querySelector(selector){if(selector==='body'||selector==='head'){return document[selector]} CloudflareApps.internal.markSelectors() var els=document.querySelectorAll('[cfapps-selector="'+selector+'"]') if(!els||!els.length){noteError({type:'select:not-found:by-attribute',selector:selector}) els=document.querySelectorAll(selector) if(!els||!els.length){noteError({type:'select:not-found:by-query',selector:selector}) return null}else if(els.length>1){noteError({type:'select:too-many:by-query',selector:selector})} return els[0]} if(els.length>1){noteError({type:'select:too-many:by-attribute',selector:selector})} return els[0]}}());(function(){'use strict' var prevEls={} CloudflareApps.createElement=function createElement(options,prevEl){options=options||{} CloudflareApps.internal.markSelectors() try{if(prevEl&&prevEl.parentNode){var replacedEl if(prevEl.cfAppsElementId){replacedEl=prevEls[prevEl.cfAppsElementId]} if(replacedEl){prevEl.parentNode.replaceChild(replacedEl,prevEl) delete prevEls[prevEl.cfAppsElementId]}else{prevEl.parentNode.removeChild(prevEl)}} var element=document.createElement('cloudflare-app') var container if(options.pages&&options.pages.URLPatterns&&!CloudflareApps.matchPage(options.pages.URLPatterns)){return element} try{container=CloudflareApps.querySelector(options.selector)}catch(e){} if(!container){return element} if(!container.parentNode&&(options.method==='after'||options.method==='before'||options.method==='replace')){return element} if(container===document.body){if(options.method==='after'){options.method='append'}else if(options.method==='before'){options.method='prepend'}} switch(options.method){case'prepend':if(container.firstChild){container.insertBefore(element,container.firstChild) break} case'append':container.appendChild(element) break case'after':if(container.nextSibling){container.parentNode.insertBefore(element,container.nextSibling)}else{container.parentNode.appendChild(element)} break case'before':container.parentNode.insertBefore(element,container) break case'replace':try{var id=element.cfAppsElementId=Math.random().toString(36) prevEls[id]=container}catch(e){} container.parentNode.replaceChild(element,container)} return element}catch(e){if(typeof console!=='undefined'&&typeof console.error!=='undefined'){console.error('Error creating Cloudflare Apps element',e)}}}}());(function(){'use strict' CloudflareApps.matchPage=function matchPage(patterns){if(!patterns||!patterns.length){return true} var loc=document.location.host+document.location.pathname if(window.CloudflareApps&&CloudflareApps.proxy&&CloudflareApps.proxy.originalURL){var url=CloudflareApps.proxy.originalURL.parsed loc=url.host+url.path} for(var i=0;i
可以尝试去cloudflare那边暂时停用cdn功能检查一下
尝试了一下,把APPS卸载,cdn改bypass之后一样是没有效果的 基本排除cloudflare的问题了
怪... 我用的是 cloudflare analytics
的 SPA
版本 没有出现这样的问题
你也许可以尝试使用 Hexo injector
而不是主题设置中的 site_analytics
项来设置统计功能
文档在这里
删除主题设置中的 site_analytics
的值
添加以下内容到 site_folder/scripts/analytics.js
hexo.extend.injector.register('head_end', '<!--Bing/Clarity Analytics--><script type="text/javascript">(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", "********");</script><!--End of Bing/Clarity Analytics-->', 'default');
怪... 我用的是
cloudflare analytics
的SPA
版本 没有出现这样的问题你也许可以尝试使用
Hexo injector
而不是主题设置中的site_analytics
项来设置统计功能 文档在这里删除主题设置中的
site_analytics
的值 添加以下内容到site_folder/scripts/analytics.js
hexo.extend.injector.register('head_end', '<!--Bing/Clarity Analytics--><script type="text/javascript">(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", "********");</script><!--End of Bing/Clarity Analytics-->', 'default');
属于是非常不理解了 晚上试试看吧🤷♀️
潜在的相关问题: https://github.com/Candinya/Kratos-Rebirth/issues/103
这个并不是主题的问题,而是 YAML 的语法规范,因为使用 : 分隔键名和键值,所以当键值里出现同样的 : 分隔符时就会出现错误,花括号在 YAML 里也是特殊符号,所以触发了无法解析的问题; 对于字符串类型,使用单引号或是双引号包括起来一般能正确解析,但由于这行代码里已经包含了单双引号,所以目前可能只有删去字符串中冒号后的空格作为比较有效的解决方案。
您好,在新的主题模式实现(#113)中,监听按钮这一步骤在DOMContentLoaded
事件触发后进行
这边注意到您开启了Cloudflare
的Rocket-Loader
,这似乎影响了DOMContentLoaded
的正常触发,导致按钮无法被监听
这似乎属于Cloudflare
的bug
See also: Understanding Rocket Loader Solution to Missing DOMContentLoaded Event when Enabling both HTML Auto Minify and Rocket Loader in Cloudflare by @HollowMan6
您好,在新的主题模式实现(#113)中,监听按钮这一步骤在
DOMContentLoaded
事件触发后进行 这边注意到您开启了Cloudflare
的Rocket-Loader
,这似乎影响了DOMContentLoaded
的正常触发,导致按钮无法被监听 这似乎属于Cloudflare
的bugSee also: Understanding Rocket Loader Solution to Missing DOMContentLoaded Event when Enabling both HTML Auto Minify and Rocket Loader in Cloudflare by @HollowMan6
非常感谢,刚刚对Rocket-Loader
的设置进行了更改,已经解决了这一问题,同时我在对相关问题进行检索后发现一篇文章有提到Rocket-Loader
对中国大陆访问者的不便利之处,可能是同一原因造成的这一问题。
再次感谢!
可能是同一原因造成的这一问题。
应该也不仅仅是墙的问题,毕竟我开着梯子也没法正常触发DOMContentLoaded
可能是同一原因造成的这一问题。
应该也不仅仅是墙的问题,毕竟我开着梯子也没法正常触发
DOMContentLoaded
我这里也是,就很奇怪,但是至少目前能暂时解决这个问题了
对Bug的描述: 页面手动暗色模式切换按钮失效
复现Bug的方法: 可以使用如下的方案进行复现: 1 使用npm安装主题v2.0.2 2 通过
npm update
升级主题至v2.0.3 3hexo g
生成网站 4 看,出错了吧!期望的行为: 按钮应可以正常手动切换暗色主题
相关的截图: 可直接访问 https://blog.ypa.moe/ 进行按钮测试
运行环境(如果该Bug的产生和环境有关,例如浏览器不兼容导致):
服务器环境 以下参数来自
hexo v
您的配置文件: /*****/_config.kratos-rebirth.yml Line 10 ...... enable_dark: true ......
补充内容: 暂无