|
@@ -1,4 +1,4 @@
|
|
|
-import { ref, shallowRef } from "vue";
|
|
|
+import { Component, ref, shallowRef } from "vue";
|
|
|
import XEUtils from "xe-utils";
|
|
|
|
|
|
interface DialogProps {
|
|
@@ -17,15 +17,24 @@ export interface DialogExpose {
|
|
|
cancel: () => any | Promise<any>;
|
|
|
}
|
|
|
|
|
|
-export namespace UseDialog {
|
|
|
- export interface Expose extends DialogExpose {}
|
|
|
+export interface UseDialog {
|
|
|
+ Expose: {} & DialogExpose;
|
|
|
|
|
|
- export interface Emits {
|
|
|
+ Emits: {
|
|
|
(e: "cyDialogConfirm" | "cyDialogCancel", value?: any): void;
|
|
|
- }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
-type FirstParam<T> = T extends Component<infer P> ? P : any;
|
|
|
+export interface UseDialogEmits {
|
|
|
+ (e: "cyDialogConfirm" | "cyDialogCancel", value?: any): void;
|
|
|
+}
|
|
|
+
|
|
|
+type FirstParam<T> =
|
|
|
+ T extends Component<infer P, any, any, any, any, any>
|
|
|
+ ? P extends Record<string, any>
|
|
|
+ ? P
|
|
|
+ : {}
|
|
|
+ : never;
|
|
|
|
|
|
export interface DialogOptions<P = Component> {
|
|
|
dialogProps: DialogProps;
|
|
@@ -50,11 +59,11 @@ export interface DialogState extends DialogOptions {
|
|
|
export const dialogStore = ref<DialogState[]>([]);
|
|
|
export const dialogKey = ref(1);
|
|
|
|
|
|
-export function useDialog<C = Component>(
|
|
|
+export function useDialog<R = any, C = Component>(
|
|
|
component: C,
|
|
|
props: DialogOptions<C>
|
|
|
) {
|
|
|
- return new Promise<any>((resolve, reject) => {
|
|
|
+ return new Promise<R>((resolve, reject) => {
|
|
|
props = {
|
|
|
visible: true,
|
|
|
component: shallowRef(component),
|