23 lines
429 B
TypeScript
23 lines
429 B
TypeScript
import { defineStore } from 'pinia';
|
|
|
|
export type Theme = 'dark' | 'light';
|
|
|
|
interface SettingsState {
|
|
theme: Theme;
|
|
}
|
|
|
|
export const useSettingsStore = defineStore('settings', {
|
|
state: (): SettingsState => ({
|
|
theme: 'dark', // Default theme
|
|
}),
|
|
|
|
actions: {
|
|
setTheme(theme: Theme) {
|
|
this.theme = theme;
|
|
},
|
|
toggleTheme() {
|
|
this.theme = this.theme === 'light' ? 'dark' : 'light';
|
|
},
|
|
},
|
|
});
|