mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
feat: 新版webui
This commit is contained in:
16
napcat.webui/src/store/index.ts
Normal file
16
napcat.webui/src/store/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { configureStore } from '@reduxjs/toolkit'
|
||||
|
||||
import configSlice from './modules/config'
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
config: configSlice
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
|
||||
// Infer the `RootState` and `AppDispatch` types from the store itself
|
||||
export type RootState = ReturnType<typeof store.getState>
|
||||
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
|
||||
export type AppDispatch = typeof store.dispatch
|
||||
37
napcat.webui/src/store/modules/config.ts
Normal file
37
napcat.webui/src/store/modules/config.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { PayloadAction, createSlice } from '@reduxjs/toolkit'
|
||||
|
||||
import type { RootState } from '@/store'
|
||||
|
||||
interface ConfigState {
|
||||
value: OneBotConfig
|
||||
}
|
||||
|
||||
const initialState: ConfigState = {
|
||||
value: {
|
||||
network: {
|
||||
httpServers: [],
|
||||
httpClients: [],
|
||||
websocketServers: [],
|
||||
websocketClients: []
|
||||
},
|
||||
musicSignUrl: '',
|
||||
enableLocalFile2Url: false,
|
||||
parseMultMsg: true
|
||||
}
|
||||
}
|
||||
|
||||
export const configSlice = createSlice({
|
||||
name: 'config',
|
||||
initialState,
|
||||
reducers: {
|
||||
updateConfig: (state, action: PayloadAction<OneBotConfig>) => {
|
||||
state.value = action.payload
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const { updateConfig } = configSlice.actions
|
||||
|
||||
export const selectCount = (state: RootState) => state.config.value
|
||||
|
||||
export default configSlice.reducer
|
||||
Reference in New Issue
Block a user