mirror of
https://github.com/mivodev/plugin-mivo-theme.git
synced 2026-01-26 13:21:58 +07:00
docs: add MIT license
This commit is contained in:
24
theme/assets/js/theme.js
Normal file
24
theme/assets/js/theme.js
Normal file
@@ -0,0 +1,24 @@
|
||||
function initTheme() {
|
||||
return {
|
||||
theme: localStorage.getItem('mivo_theme') || 'dark',
|
||||
toggle() {
|
||||
this.theme = this.theme === 'dark' ? 'light' : 'dark';
|
||||
this.apply();
|
||||
},
|
||||
setTheme(val) {
|
||||
this.theme = val;
|
||||
this.apply();
|
||||
},
|
||||
apply() {
|
||||
localStorage.setItem('mivo_theme', this.theme);
|
||||
if (this.theme === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user