mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 19:29:04 +08:00
chore: bump 2.0.0-rc.11
This commit is contained in:
@@ -9,8 +9,7 @@ export interface ModalMethods {
|
||||
|
||||
export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
|
||||
export interface ReturnMethods extends ModalMethods {
|
||||
openModal: <T = any>(props?: boolean, data?: T) => void;
|
||||
transferModalData: (data: any) => void;
|
||||
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
|
||||
}
|
||||
export type UseModalReturnType = [RegisterFn, ReturnMethods];
|
||||
|
||||
@@ -18,7 +17,6 @@ export interface ReturnInnerMethods extends ModalMethods {
|
||||
closeModal: () => void;
|
||||
changeLoading: (loading: boolean) => void;
|
||||
changeOkLoading: (loading: boolean) => void;
|
||||
receiveModalDataRef: any;
|
||||
}
|
||||
export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
|
||||
|
||||
|
@@ -5,16 +5,7 @@ import type {
|
||||
ReturnMethods,
|
||||
UseModalInnerReturnType,
|
||||
} from './types';
|
||||
import {
|
||||
ref,
|
||||
onUnmounted,
|
||||
unref,
|
||||
getCurrentInstance,
|
||||
reactive,
|
||||
computed,
|
||||
watchEffect,
|
||||
nextTick,
|
||||
} from 'vue';
|
||||
import { ref, onUnmounted, unref, getCurrentInstance, reactive, watchEffect, nextTick } from 'vue';
|
||||
import { isProdMode } from '/@/utils/env';
|
||||
import { isFunction } from '/@/utils/is';
|
||||
const dataTransferRef = reactive<any>({});
|
||||
@@ -55,18 +46,19 @@ export function useModal(): UseModalReturnType {
|
||||
getInstance().setModalProps(props);
|
||||
},
|
||||
|
||||
openModal: <T = any>(visible = true, data?: T): void => {
|
||||
openModal: <T = any>(visible = true, data?: T, openOnSet = false): void => {
|
||||
getInstance().setModalProps({
|
||||
visible: visible,
|
||||
});
|
||||
if (data) {
|
||||
dataTransferRef[unref(uidRef)] = data;
|
||||
dataTransferRef[unref(uidRef)] = openOnSet
|
||||
? {
|
||||
...data,
|
||||
__t__: Date.now(),
|
||||
}
|
||||
: data;
|
||||
}
|
||||
},
|
||||
|
||||
transferModalData(val: any) {
|
||||
dataTransferRef[unref(uidRef)] = val;
|
||||
},
|
||||
};
|
||||
return [register, methods];
|
||||
}
|
||||
@@ -106,10 +98,6 @@ export const useModalInner = (callbackFn?: Fn): UseModalInnerReturnType => {
|
||||
return [
|
||||
register,
|
||||
{
|
||||
receiveModalDataRef: computed(() => {
|
||||
return dataTransferRef[unref(uidRef)];
|
||||
}),
|
||||
|
||||
changeLoading: (loading = true) => {
|
||||
getInstance().setModalProps({ loading });
|
||||
},
|
||||
|
Reference in New Issue
Block a user