This commit is contained in:
dap
2025-01-01 12:57:20 +08:00
251 changed files with 619 additions and 959 deletions

View File

@@ -100,17 +100,6 @@ describe('drawerApi', () => {
expect(onOpenChange).toHaveBeenCalledWith(true);
});
it('should batch state updates', () => {
const batchSpy = vi.spyOn(drawerApi.store, 'batch');
drawerApi.batchStore(() => {
drawerApi.setState({ title: 'Batch Title' });
drawerApi.setState({ confirmText: 'Batch Confirm' });
});
expect(batchSpy).toHaveBeenCalled();
expect(drawerApi.store.state.title).toBe('Batch Title');
expect(drawerApi.store.state.confirmText).toBe('Batch Confirm');
});
it('should call onClosed callback when provided', () => {
const onClosed = vi.fn();
const drawerApiWithHook = new DrawerApi({ onClosed });

View File

@@ -83,11 +83,6 @@ export class DrawerApi {
bindMethods(this);
}
// 如果需要多次更新状态,可以使用 batch 方法
batchStore(cb: () => void) {
this.store.batch(cb);
}
/**
* 关闭弹窗
*/

View File

@@ -1,9 +1,8 @@
import type { ClassType } from '@vben-core/typings';
import type { Component, Ref } from 'vue';
import type { DrawerApi } from './drawer-api';
import type { Component, Ref } from 'vue';
export type DrawerPlacement = 'bottom' | 'left' | 'right' | 'top';
export type CloseIconPlacement = 'left' | 'right';

View File

@@ -4,6 +4,7 @@ import type {
ExtendedDrawerApi,
} from './drawer';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -14,8 +15,6 @@ import {
ref,
} from 'vue';
import { useStore } from '@vben-core/shared/store';
import VbenDrawer from './drawer.vue';
import { DrawerApi } from './drawer-api';