use new frontend

This commit is contained in:
felinae98
2022-07-31 00:05:22 +08:00
parent 22f6796b33
commit 1d7d9b8fde
43 changed files with 3438 additions and 4667 deletions
@@ -0,0 +1,35 @@
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { RootState } from '../../app/store';
import { GlobalConf } from '../../utils/type';
import { globalConfUrl } from '../../utils/urls';
const initialState = {
loaded: false,
platformConf: {},
} as GlobalConf;
export const loadGlobalConf = createAsyncThunk(
'globalConf/load',
async () => {
const res = await fetch(globalConfUrl);
return (await res.json()) as GlobalConf;
},
);
export const globalConfSlice = createSlice({
name: 'globalConf',
initialState,
reducers: {},
extraReducers(builder) {
builder
.addCase(loadGlobalConf.fulfilled, (state, payload) => {
state.platformConf = payload.payload.platformConf;
state.loaded = true;
});
},
});
export default globalConfSlice.reducer;
export const selectGlobalConfLoaded = (state: RootState) => state.globalConf.loaded;
export const selectPlatformConf = (state: RootState) => state.globalConf.platformConf;