This commit is contained in:
dap
2025-01-15 15:22:21 +08:00
53 changed files with 267 additions and 126 deletions

View File

@@ -1,3 +1,3 @@
export type * from './drawer';
export { default as VbenDrawer } from './drawer.vue';
export { useVbenDrawer } from './use-drawer';
export { setDefaultDrawerProps, useVbenDrawer } from './use-drawer';

View File

@@ -4,7 +4,6 @@ import type {
ExtendedDrawerApi,
} from './drawer';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -15,11 +14,19 @@ import {
ref,
} from 'vue';
import VbenDrawer from './drawer.vue';
import { useStore } from '@vben-core/shared/store';
import { DrawerApi } from './drawer-api';
import VbenDrawer from './drawer.vue';
const USER_DRAWER_INJECT_KEY = Symbol('VBEN_DRAWER_INJECT');
const DEFAULT_DRAWER_PROPS: Partial<DrawerProps> = {};
export function setDefaultDrawerProps(props: Partial<DrawerProps>) {
Object.assign(DEFAULT_DRAWER_PROPS, props);
}
export function useVbenDrawer<
TParentDrawerProps extends DrawerProps = DrawerProps,
>(options: DrawerApiOptions = {}) {
@@ -68,6 +75,7 @@ export function useVbenDrawer<
const injectData = inject<any>(USER_DRAWER_INJECT_KEY, {});
const mergedOptions = {
...DEFAULT_DRAWER_PROPS,
...injectData.options,
...options,
} as DrawerApiOptions;

View File

@@ -1,3 +1,3 @@
export type * from './modal';
export { default as VbenModal } from './modal.vue';
export { useVbenModal } from './use-modal';
export { setDefaultModalProps, useVbenModal } from './use-modal';

View File

@@ -1,6 +1,5 @@
import type { ExtendedModalApi, ModalApiOptions, ModalProps } from './modal';
import { useStore } from '@vben-core/shared/store';
import {
defineComponent,
h,
@@ -11,11 +10,19 @@ import {
ref,
} from 'vue';
import VbenModal from './modal.vue';
import { useStore } from '@vben-core/shared/store';
import { ModalApi } from './modal-api';
import VbenModal from './modal.vue';
const USER_MODAL_INJECT_KEY = Symbol('VBEN_MODAL_INJECT');
const DEFAULT_MODAL_PROPS: Partial<ModalProps> = {};
export function setDefaultModalProps(props: Partial<ModalProps>) {
Object.assign(DEFAULT_MODAL_PROPS, props);
}
export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
options: ModalApiOptions = {},
) {
@@ -67,6 +74,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
const injectData = inject<any>(USER_MODAL_INJECT_KEY, {});
const mergedOptions = {
...DEFAULT_MODAL_PROPS,
...injectData.options,
...options,
} as ModalApiOptions;