2
0

初始化项目

This commit is contained in:
caiyuchao
2024-11-14 11:06:38 +08:00
parent 988b9e6799
commit 4ffac789e1
320 changed files with 34244 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import type { PiniaPluginContext } from 'pinia';
import { cloneDeep } from 'lodash-es';
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 = cloneDeep($state);
context.store.$reset = () => {
context.store.$patch(defaultStore);
};
}
}