mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
36 lines
758 B
JavaScript
36 lines
758 B
JavaScript
import create from 'zustand';
|
|
import { DEFAULT_LOCALE, DEFAULT_THEME, LOCALE_CONFIG, THEME_CONFIG } from 'lib/constants';
|
|
import { getItem } from 'lib/web';
|
|
|
|
const initialState = {
|
|
locale: getItem(LOCALE_CONFIG) || DEFAULT_LOCALE,
|
|
theme: getItem(THEME_CONFIG) || DEFAULT_THEME,
|
|
shareToken: null,
|
|
user: null,
|
|
config: null,
|
|
};
|
|
|
|
const store = create(() => ({ ...initialState }));
|
|
|
|
export function setTheme(theme) {
|
|
store.setState({ theme });
|
|
}
|
|
|
|
export function setLocale(locale) {
|
|
store.setState({ locale });
|
|
}
|
|
|
|
export function setShareToken(shareToken) {
|
|
store.setState({ shareToken });
|
|
}
|
|
|
|
export function setUser(user) {
|
|
store.setState({ user });
|
|
}
|
|
|
|
export function setConfig(config) {
|
|
store.setState({ config });
|
|
}
|
|
|
|
export default store;
|