Skip to content

Commit

Permalink
perf(debug): env pjax rightMenus
Browse files Browse the repository at this point in the history
  • Loading branch information
MHuiG committed Sep 5, 2022
1 parent a264a8c commit 7b569cc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
theme_docs: https://volantis.js.org/ # This is theme's URL.
theme_repo: https://github.com/volantis-x/hexo-theme-volantis
# Debug 调试模式
debug: false
debug: env # false: 关闭调试模式, env:环境配置检查, pjax:调试pjax,rightMenus: 调试右键
############################### 默认占位图 ###############################
default:
avatar: volantis-static/media/placeholder/avatar/round/3442075.svg # https://cdn.jsdelivr.net/gh/cdn-x/[email protected]/avatar/round/3442075.svg
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/scripts/global.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
/************这个文件存放不需要重载的全局变量和全局函数*********/
window.volantis = {}; // volantis 全局变量
volantis.debug = <%- theme.debug %>; // 开启调试模式
volantis.debug = "<%- theme.debug %>"; // 调试模式
volantis.dom = {}; // 页面Dom see: /source/js/app.js etc.
volantis.GLOBAL_CONFIG ={
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/pjax/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
cacheBust: <%= theme.plugins.pjax.cacheBust %>, // url 地址追加时间戳,用以避免浏览器缓存
timeout: <%= theme.plugins.pjax.timeout %>,
<% if (theme.debug){ %> debug: true,<% } %>
<% if (theme.debug === "pjax"){ %> debug: true,<% } %>
});
});
Expand Down
4 changes: 3 additions & 1 deletion scripts/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ hexo.on('generateBefore', () => {
require('./lib/config')(hexo);
require('./lib/stellar-tag-utils')(hexo);
require('./lib/render-stylus')(hexo);
require('./lib/check-environment')(hexo);
if (hexo.theme.config.debug === "env") {
require('./lib/check-environment')(hexo);
}
});

hexo.on('ready', () => {
Expand Down
8 changes: 8 additions & 0 deletions scripts/events/lib/check-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Hexo: 5.4 ~ 6.x
hexo-cli: 4.3 ~ latest
node.js: 16.x LTS ~ latest LTS
npm: 8.x ~ latest LTS
============================================================
# 当前 Debug 调试模式
debug: env
关闭调试模式主题配置文件设置 debug: false
============================================================`);
throw new Error('环境配置检查失败!| Environment configuration check failed!');
}
Expand All @@ -67,6 +71,10 @@ function CheckConfError(hexo,msg) {
配置文件检查失败!| Configuration check failed!
============================================================
${msg}
============================================================
# 当前 Debug 调试模式
debug: env
关闭调试模式主题配置文件设置 debug: false
============================================================`);
throw new Error('配置文件检查失败!| Configuration check failed!');
}
2 changes: 1 addition & 1 deletion source/js/plugins/rightMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ RightMenus.fun = (() => {
fn[eventName]()
}
} catch (error) {
if (volantis.GLOBAL_CONFIG.debug) {
if (volantis.GLOBAL_CONFIG.debug === "rightMenus") {
console.error({
id: id,
error: error,
Expand Down

0 comments on commit 7b569cc

Please sign in to comment.