mirror of
https://github.com/certd/certd.git
synced 2026-05-18 06:17:31 +08:00
chore: code format
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
import type { ExtendedModalApi, ModalApiOptions, ModalProps } from './modal';
|
||||
import type { ExtendedModalApi, ModalApiOptions, ModalProps } from "./modal";
|
||||
|
||||
import {
|
||||
defineComponent,
|
||||
h,
|
||||
inject,
|
||||
nextTick,
|
||||
provide,
|
||||
reactive,
|
||||
ref,
|
||||
} from 'vue';
|
||||
import { defineComponent, h, inject, nextTick, provide, reactive, ref } from "vue";
|
||||
|
||||
import { useStore } from '/@/vben/shared/store';
|
||||
import { useStore } from "/@/vben/shared/store";
|
||||
|
||||
import { ModalApi } from './modal-api';
|
||||
import VbenModal from './modal.vue';
|
||||
import { ModalApi } from "./modal-api";
|
||||
import VbenModal from "./modal.vue";
|
||||
|
||||
const USER_MODAL_INJECT_KEY = Symbol('VBEN_MODAL_INJECT');
|
||||
const USER_MODAL_INJECT_KEY = Symbol("VBEN_MODAL_INJECT");
|
||||
|
||||
const DEFAULT_MODAL_PROPS: Partial<ModalProps> = {};
|
||||
|
||||
@@ -23,9 +15,7 @@ export function setDefaultModalProps(props: Partial<ModalProps>) {
|
||||
Object.assign(DEFAULT_MODAL_PROPS, props);
|
||||
}
|
||||
|
||||
export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
options: ModalApiOptions = {},
|
||||
) {
|
||||
export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(options: ModalApiOptions = {}) {
|
||||
// Modal一般会抽离出来,所以如果有传入 connectedComponent,则表示为外部调用,与内部组件进行连接
|
||||
// 外部的Modal通过provide/inject传递api
|
||||
|
||||
@@ -55,18 +45,18 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
});
|
||||
return () =>
|
||||
h(
|
||||
isModalReady.value ? connectedComponent : 'div',
|
||||
isModalReady.value ? connectedComponent : "div",
|
||||
{
|
||||
...props,
|
||||
...attrs,
|
||||
},
|
||||
slots,
|
||||
slots
|
||||
);
|
||||
},
|
||||
{
|
||||
inheritAttrs: false,
|
||||
name: 'VbenParentModal',
|
||||
},
|
||||
name: "VbenParentModal",
|
||||
}
|
||||
);
|
||||
return [Modal, extendedApi as ExtendedModalApi] as const;
|
||||
}
|
||||
@@ -96,7 +86,7 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
|
||||
const extendedApi: ExtendedModalApi = api as never;
|
||||
|
||||
extendedApi.useStore = (selector) => {
|
||||
extendedApi.useStore = selector => {
|
||||
return useStore(api.store, selector);
|
||||
};
|
||||
|
||||
@@ -110,13 +100,13 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
...attrs,
|
||||
modalApi: extendedApi,
|
||||
},
|
||||
slots,
|
||||
slots
|
||||
);
|
||||
},
|
||||
{
|
||||
inheritAttrs: false,
|
||||
name: 'VbenModal',
|
||||
},
|
||||
name: "VbenModal",
|
||||
}
|
||||
);
|
||||
injectData.extendApi?.(extendedApi);
|
||||
return [Modal, extendedApi] as const;
|
||||
@@ -137,11 +127,9 @@ async function checkProps(api: ExtendedModalApi, attrs: Record<string, any>) {
|
||||
const stateKeys = new Set(Object.keys(state));
|
||||
|
||||
for (const attr of Object.keys(attrs)) {
|
||||
if (stateKeys.has(attr) && !['class'].includes(attr)) {
|
||||
if (stateKeys.has(attr) && !["class"].includes(attr)) {
|
||||
// connectedComponent存在时,不要传入Modal的props,会造成复杂度提升,如果你需要修改Modal的props,请使用 useModal 或者api
|
||||
console.warn(
|
||||
`[Vben Modal]: When 'connectedComponent' exists, do not set props or slots '${attr}', which will increase complexity. If you need to modify the props of Modal, please use useVbenModal or api.`,
|
||||
);
|
||||
console.warn(`[Vben Modal]: When 'connectedComponent' exists, do not set props or slots '${attr}', which will increase complexity. If you need to modify the props of Modal, please use useVbenModal or api.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user