Files
fateverse-react/src/stores/cache.ts
2023-10-13 16:23:20 +08:00

27 lines
510 B
TypeScript

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