This commit is contained in:
2025-12-16 20:20:53 +07:00
commit 2e651f1c89
315 changed files with 33529 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import type { PiniaPluginContext } from 'pinia';
import { jsonClone } from '@sa/utils';
import { SetupStoreId } from '@/enum';
/**
* The plugin reset the state of the store which is written by setup syntax
*
* @param context
*/
export function resetSetupStore(context: PiniaPluginContext) {
const setupSyntaxIds = Object.values(SetupStoreId) as string[];
if (setupSyntaxIds.includes(context.store.$id)) {
const { $state } = context.store;
const defaultStore = jsonClone($state);
context.store.$reset = () => {
context.store.$patch(defaultStore);
};
}
}