初始化fateverse
This commit is contained in:
27
src/stores/cache.ts
Normal file
27
src/stores/cache.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createSlice } from '@reduxjs/toolkit'
|
||||
|
||||
type CacheKey = string
|
||||
|
||||
type CacheVal = any
|
||||
|
||||
const initCache = new Map<CacheKey, CacheVal>([])
|
||||
|
||||
// 创建一个slice
|
||||
export const cacheSlice = createSlice({
|
||||
name: 'cache',
|
||||
|
||||
// 初始化数据状态
|
||||
initialState: {},
|
||||
|
||||
// 定义改变数据状态的方法
|
||||
reducers: {
|
||||
addCache(state, { payload }) {
|
||||
state = {...state, ...payload}
|
||||
return state
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const { addCache } = cacheSlice.actions
|
||||
|
||||
export default cacheSlice.reducer
|
||||
Reference in New Issue
Block a user