You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
381 B
TypeScript

import type { PiniaPluginContext } from 'pinia'
import { cloneDeep } from '~/utils'
/**
* setup语法的重置状态插件
*/
export function resetSetupStorePlugin(context: PiniaPluginContext) {
const initialState = cloneDeep(context.store.$state)
context.store.$reset = () => {
context.store.$patch(($state) => {
Object.assign($state, initialState)
})
}
}