feat: files draft
This commit is contained in:
@@ -32,7 +32,7 @@ import { updateInfo } from "../slices/server";
|
||||
import { updateCallInfo, upsertVoiceList } from "../slices/voice";
|
||||
import { RootState } from "../store";
|
||||
import baseQuery from "./base.query";
|
||||
import { File, GetFilesDTO } from "@/types/resource";
|
||||
import { GetFilesDTO, VoceChatFile } from "@/types/resource";
|
||||
|
||||
export const serverApi = createApi({
|
||||
reducerPath: "serverApi",
|
||||
@@ -239,7 +239,7 @@ export const serverApi = createApi({
|
||||
getLoginConfig: builder.query<LoginConfig, void>({
|
||||
query: () => ({ url: `/admin/login/config` })
|
||||
}),
|
||||
getFiles: builder.query<File[], GetFilesDTO>({
|
||||
getFiles: builder.query<VoceChatFile[], GetFilesDTO>({
|
||||
query: (params) => ({
|
||||
url: `/admin/system/files?${new URLSearchParams(
|
||||
params as Record<string, string>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { VoceChatFile } from "@/types/resource";
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
const initialState: VoceChatFile[] = [];
|
||||
|
||||
const filesSlice = createSlice({
|
||||
name: `files`,
|
||||
initialState,
|
||||
reducers: {
|
||||
fillFiles(state, action: PayloadAction<VoceChatFile[]>) {
|
||||
return action.payload;
|
||||
},
|
||||
addFile(state, action: PayloadAction<VoceChatFile>) {
|
||||
state.push(action.payload);
|
||||
},
|
||||
deleteFile(state, action: PayloadAction<string>) {
|
||||
const content = action.payload;
|
||||
const idx = state.findIndex((f) => f.content == content);
|
||||
if (idx > -1) {
|
||||
state.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const { addFile, deleteFile, fillFiles } = filesSlice.actions;
|
||||
|
||||
export default filesSlice.reducer;
|
||||
@@ -13,6 +13,7 @@ import channelsReducer from "./slices/channels";
|
||||
import favoritesReducer from "./slices/favorites";
|
||||
import footprintReducer from "./slices/footprint";
|
||||
import messageReducer from "./slices/message";
|
||||
import filesReducer from "./slices/files";
|
||||
import archiveMsgReducer from "./slices/message.archive";
|
||||
import channelMsgReducer from "./slices/message.channel";
|
||||
import fileMsgReducer from "./slices/message.file";
|
||||
@@ -38,6 +39,7 @@ const reducer = combineReducers({
|
||||
fileMessage: fileMsgReducer,
|
||||
archiveMessage: archiveMsgReducer,
|
||||
message: messageReducer,
|
||||
files: filesReducer,
|
||||
[authApi.reducerPath]: authApi.reducer,
|
||||
[messageApi.reducerPath]: messageApi.reducer,
|
||||
[userApi.reducerPath]: userApi.reducer,
|
||||
|
||||
Reference in New Issue
Block a user