Skip to content

Commit

Permalink
✨ feat: add debugMode switch
Browse files Browse the repository at this point in the history
Ciallo~(∠・ω<)⌒☆
  • Loading branch information
latedreamdev committed Aug 28, 2024
1 parent 388d5ee commit 5a5cd70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,21 @@ <h2 class="page-title" al="config"></h2>
<mdui-slider class="inline-block searchable-prompt-length" name="searchable-prompt-length"
value="10" min="0" max="30"></mdui-slider>
</label>
<label al="debugFuncs" debugFuncs>debugFuncs</label>
<label debugFuncs>
<span debugFuncs>
<label al="debugFuncs">debugFuncs</label>
<label>
<input id="debugMode" type="checkbox" onclick="" disabled>
<text al="debugMode">debugMode</text>
</label>
<label>
<input id="clickEffect" type="checkbox" onclick="this.disabled = true;">
<text al="clickEffect">clickEffect</text>
</label>
<label debugFuncs>
<label>
<input id="githubRepoProxy" type="checkbox" onclick="">
<text al="githubRepoProxy">githubRepoProxy</text>
</label>
</span>
</div>
<div class="ellipsis">
<h2 al="ellipsis"></h2>
Expand Down
12 changes: 9 additions & 3 deletions scripts/debug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// 调试模式 (Debug Mode)
const debugCallback = (e = $('[debugFuncs]')) => (debug.mode ? e.show() : e.hide());
const debugCallback = (e = $('[debugFuncs]')) => {
debug.mode ? e.show() : e.hide();
$('#debugMode')[0].checked = debug.mode;
$('#debugMode')[0].disabled = !debug.mode;
console.log(`[debug] debugMode is now ${debug.mode? "enabled": "disabled"}`);
};
const debugChange = ((object) => {
const handler = {
defineProperty: (target, property, descriptor) => {
Expand All @@ -12,6 +17,7 @@ const debugChange = ((object) => {
const debug = debugChange({mode: (location.hostname === "127.0.0.1" || location.hostname === "localhost")});
debugCallback();

$('#debugMode').change(() => debug.mode = $('#debugMode')[0].checked);
// 点击特效:此处包含外链地址,内容由XiaozhiSans提供。如果您需要使用,应先询问其意见。
$('#clickEffect').change(() => {
if ($('#clickEffect')[0].checked) $.getScript('https://log.xsawa.dev.tc/js/candy.min.js')
Expand All @@ -25,12 +31,12 @@ $('#githubRepoProxy').change(() => {
try {$('a').each(function() {
if (this.href && this.href.startsWith('https://github.com'))
this.href = this.href.replace('https://github.com', proxy);
})} catch(e) {console.error(e)}
}) && console.log(`[debug] githubRepoProxy is now enabled\nproxy url = ${proxy}`)} catch(e) {console.error(e)}
} else {
try {$('a').each(function() {
if (this.href && this.href.startsWith(proxy))
this.href = this.href.replace(proxy, 'https://github.com');
})} catch(e) {console.error(e)}
}) && console.log("[debug] githubRepoProxy is now disabled")} catch(e) {console.error(e)}
}
});

Expand Down

0 comments on commit 5a5cd70

Please sign in to comment.