refactor: Separate store

This commit is contained in:
vben
2024-07-30 21:10:28 +08:00
parent cf0ec053e4
commit 89dcf522f5
40 changed files with 338 additions and 345 deletions

View File

@@ -1,5 +1,7 @@
import type { Pinia } from 'pinia';
import type { App } from 'vue';
import { createPinia } from 'pinia';
let pinia: Pinia;
@@ -14,7 +16,7 @@ export interface InitStoreOptions {
/**
* @zh_CN 初始化pinia
*/
export async function initStore(options: InitStoreOptions) {
export async function initStores(app: App, options: InitStoreOptions) {
const { createPersistedState } = await import('pinia-plugin-persistedstate');
pinia = createPinia();
const { namespace } = options;
@@ -25,6 +27,7 @@ export async function initStore(options: InitStoreOptions) {
storage: localStorage,
}),
);
app.use(pinia);
return pinia;
}