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('modalApi', () => {
expect(onOpenChange).toHaveBeenCalledWith(true);
});
it('should batch state updates', () => {
const batchSpy = vi.spyOn(modalApi.store, 'batch');
modalApi.batchStore(() => {
modalApi.setState({ title: 'Batch Title' });
modalApi.setState({ confirmText: 'Batch Confirm' });
});
expect(batchSpy).toHaveBeenCalled();
expect(modalApi.store.state.title).toBe('Batch Title');
expect(modalApi.store.state.confirmText).toBe('Batch Confirm');
});
it('should call onClosed callback when provided', () => {
const onClosed = vi.fn();
const modalApiWithHook = new ModalApi({ onClosed });

View File

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

View File

@@ -1,7 +1,7 @@
import type { ModalApi } from './modal-api';
import type { Component, Ref } from 'vue';
import type { ModalApi } from './modal-api';
export interface ModalProps {
/**
* 是否要挂载到内容区域

View File

@@ -3,10 +3,10 @@
* 调整部分细节
*/
import { onBeforeUnmount, onMounted, reactive, ref, watchEffect } from 'vue';
import type { ComputedRef, Ref } from 'vue';
import { unrefElement } from '@vueuse/core';
import { onBeforeUnmount, onMounted, reactive, ref, watchEffect } from 'vue';
export function useModalDraggable(
targetRef: Ref<HTMLElement | undefined>,

View File

@@ -1,5 +1,6 @@
import type { ExtendedModalApi, ModalApiOptions, ModalProps } from './modal';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -10,8 +11,6 @@ import {
ref,
} from 'vue';
import { useStore } from '@vben-core/shared/store';
import VbenModal from './modal.vue';
import { ModalApi } from './modal-api';