chore: update app name
This commit is contained in:
16
apps/web-antd/src/store/index.ts
Normal file
16
apps/web-antd/src/store/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { InitStoreOptions } from '@vben-core/stores';
|
||||
|
||||
import { initStore } from '@vben-core/stores';
|
||||
|
||||
import type { App } from 'vue';
|
||||
|
||||
/**
|
||||
* @zh_CN 初始化pinia
|
||||
* @param app vue app 实例
|
||||
*/
|
||||
async function setupStore(app: App, options: InitStoreOptions) {
|
||||
const pinia = await initStore(options);
|
||||
app.use(pinia);
|
||||
}
|
||||
|
||||
export { setupStore };
|
17
apps/web-antd/src/store/modules/example.test.ts
Normal file
17
apps/web-antd/src/store/modules/example.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
|
||||
import { useCounterStore } from './example';
|
||||
|
||||
describe('useCounterStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it('count test', () => {
|
||||
setActivePinia(createPinia());
|
||||
const counterStore = useCounterStore();
|
||||
|
||||
expect(counterStore.count).toBe(0);
|
||||
});
|
||||
});
|
14
apps/web-antd/src/store/modules/example.ts
Normal file
14
apps/web-antd/src/store/modules/example.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useCounterStore = defineStore('counter', {
|
||||
actions: {
|
||||
increment() {
|
||||
this.count++;
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
double: (state) => state.count * 2,
|
||||
},
|
||||
persist: [],
|
||||
state: () => ({ count: 0 }),
|
||||
});
|
Reference in New Issue
Block a user