修复bug
This commit is contained in:
1 parent
331af9074a
commit
e6d50f3611
3 files changed
+107
-118
No files matched your search
@@ -123,20 +123,33 @@ window.initFloatingTools = function() {
|
||||
};
|
||||
updateIcon();
|
||||
|
||||
themeToggle.addEventListener('click', function() {
|
||||
themeToggle.addEventListener('click', function(e) {
|
||||
var currentTheme = document.documentElement.getAttribute('data-theme');
|
||||
var newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
updateIcon();
|
||||
|
||||
// Trigger Artalk theme update
|
||||
if (window.artalk && typeof window.artalk.setDarkMode === 'function') {
|
||||
window.artalk.setDarkMode(newTheme === 'dark');
|
||||
}
|
||||
|
||||
if (window.showToast) {
|
||||
window.showToast('已切换至 ' + (newTheme === 'dark' ? '深色' : '浅色') + '模式', 'success');
|
||||
if (typeof themeSweep === 'function') {
|
||||
var apply = function() {
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
updateIcon();
|
||||
if (window.artalk && typeof window.artalk.setDarkMode === 'function') {
|
||||
window.artalk.setDarkMode(newTheme === 'dark');
|
||||
}
|
||||
if (window.showToast) {
|
||||
window.showToast('已切换至 ' + (newTheme === 'dark' ? '深色' : '浅色') + '模式', 'success');
|
||||
}
|
||||
};
|
||||
themeSweep(newTheme, apply);
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
updateIcon();
|
||||
if (window.artalk && typeof window.artalk.setDarkMode === 'function') {
|
||||
window.artalk.setDarkMode(newTheme === 'dark');
|
||||
}
|
||||
if (window.showToast) {
|
||||
window.showToast('已切换至 ' + (newTheme === 'dark' ? '深色' : '浅色') + '模式', 'success');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user