fix: add debounce to theme toggle to prevent flash-back

This commit is contained in:
2026-07-25 21:22:34 +08:00
parent 7ca1053175
commit 5854b4cc57
+4
View File
@@ -1,5 +1,6 @@
const Theme = { const Theme = {
_current: 'dark', _current: 'dark',
_toggling: false,
init() { init() {
this._current = localStorage.getItem('turbosu-theme') || 'dark'; this._current = localStorage.getItem('turbosu-theme') || 'dark';
@@ -7,8 +8,11 @@ const Theme = {
}, },
toggle() { toggle() {
if (this._toggling) return;
this._toggling = true;
this._current = this._current === 'dark' ? 'light' : 'dark'; this._current = this._current === 'dark' ? 'light' : 'dark';
this.apply(); this.apply();
setTimeout(() => { this._toggling = false; }, 200);
}, },
apply() { apply() {