mirror of https://github.com/usememos/memos
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
3 years ago
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||
|
|
||
|
interface State {
|
||
|
locale: Locale;
|
||
3 years ago
|
appearance: Appearance;
|
||
3 years ago
|
systemStatus: SystemStatus;
|
||
3 years ago
|
}
|
||
|
|
||
|
const globalSlice = createSlice({
|
||
|
name: "global",
|
||
3 years ago
|
initialState: {
|
||
|
locale: "en",
|
||
3 years ago
|
appearance: "system",
|
||
3 years ago
|
systemStatus: {
|
||
|
host: undefined,
|
||
|
profile: {
|
||
|
mode: "dev",
|
||
|
version: "",
|
||
|
},
|
||
|
dbSize: 0,
|
||
|
allowSignUp: false,
|
||
|
additionalStyle: "",
|
||
|
additionalScript: "",
|
||
|
},
|
||
|
} as State,
|
||
3 years ago
|
reducers: {
|
||
|
setGlobalState: (_, action: PayloadAction<State>) => {
|
||
|
return action.payload;
|
||
|
},
|
||
|
setLocale: (state, action: PayloadAction<Locale>) => {
|
||
|
return {
|
||
|
...state,
|
||
|
locale: action.payload,
|
||
|
};
|
||
|
},
|
||
3 years ago
|
setAppearance: (state, action: PayloadAction<Appearance>) => {
|
||
|
return {
|
||
|
...state,
|
||
|
appearance: action.payload,
|
||
|
};
|
||
|
},
|
||
3 years ago
|
},
|
||
|
});
|
||
|
|
||
3 years ago
|
export const { setGlobalState, setLocale, setAppearance } = globalSlice.actions;
|
||
3 years ago
|
|
||
|
export default globalSlice.reducer;
|