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.
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
interface State {
|
|
locale: Locale;
|
|
appearance: Appearance;
|
|
systemStatus: SystemStatus;
|
|
}
|
|
|
|
const globalSlice = createSlice({
|
|
name: "global",
|
|
initialState: {
|
|
locale: "en",
|
|
appearance: "system",
|
|
systemStatus: {
|
|
host: undefined,
|
|
profile: {
|
|
mode: "dev",
|
|
version: "",
|
|
},
|
|
dbSize: 0,
|
|
allowSignUp: false,
|
|
disablePublicMemos: false,
|
|
additionalStyle: "",
|
|
additionalScript: "",
|
|
customizedProfile: {
|
|
name: "memos",
|
|
logoUrl: "/logo.png",
|
|
description: "",
|
|
locale: "en",
|
|
appearance: "system",
|
|
externalUrl: "",
|
|
},
|
|
},
|
|
} as State,
|
|
reducers: {
|
|
setGlobalState: (state, action: PayloadAction<Partial<State>>) => {
|
|
return {
|
|
...state,
|
|
...action.payload,
|
|
};
|
|
},
|
|
setLocale: (state, action: PayloadAction<Locale>) => {
|
|
return {
|
|
...state,
|
|
locale: action.payload,
|
|
};
|
|
},
|
|
setAppearance: (state, action: PayloadAction<Appearance>) => {
|
|
return {
|
|
...state,
|
|
appearance: action.payload,
|
|
};
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { setGlobalState, setLocale, setAppearance } = globalSlice.actions;
|
|
|
|
export default globalSlice.reducer;
|