feat: 增加练题
This commit is contained in:
@@ -1,23 +1,33 @@
|
||||
import { createSlice } from '@reduxjs/toolkit'
|
||||
|
||||
export interface CounterState {
|
||||
value: number
|
||||
title: string
|
||||
export interface UserInfo {
|
||||
nickName?: string
|
||||
phone?: string
|
||||
email?: string
|
||||
sex?: string | number
|
||||
introduce?: string
|
||||
avatar?: string
|
||||
}
|
||||
const initialState: CounterState = {
|
||||
value: 0,
|
||||
title: 'redux toolkit pre'
|
||||
const initialState: UserInfo = {
|
||||
nickName: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
sex: undefined,
|
||||
introduce: '',
|
||||
avatar: ''
|
||||
}
|
||||
|
||||
// 创建一个 Slice
|
||||
export const userInfoSlice = createSlice({
|
||||
name: 'userInfo',
|
||||
initialState,
|
||||
initialState: {
|
||||
userInfo: initialState
|
||||
},
|
||||
// 定义 reducers 并生成关联的操作
|
||||
reducers: {
|
||||
// 定义一个加的方法
|
||||
saveUserInfo: (state, { payload }) => {
|
||||
state.value = payload
|
||||
state.userInfo = { ...state.userInfo, ...payload }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user