mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Replaced redux with zustand. Fixed login issue, closes #980.
This commit is contained in:
parent
7071f5fba5
commit
9937caa569
33 changed files with 234 additions and 286 deletions
30
store/app.js
Normal file
30
store/app.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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,
|
||||
};
|
||||
|
||||
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 default store;
|
||||
Loading…
Add table
Add a link
Reference in a new issue