song-ui-u
Version:
vue3 + js的PC前端组件库
37 lines (34 loc) • 851 B
JavaScript
import { getCurrentInstance } from 'vue';
import { types } from '../../../../utils/types.mjs';
import 'song-ui-pro-icon';
function useDrawerEvent({ props, visible, isLoading }) {
const { emit } = getCurrentInstance();
const useBeforeCancel = () => {
useClose();
emit("cancel");
};
const useBeforeChange = () => {
const isFunction = types().isFunction(props.beforeChange);
if (isFunction) {
isLoading.value = true;
props.beforeChange().then(() => {
isLoading.value = false;
emit("ok");
}).catch(() => {
isLoading.value = false;
});
return;
}
emit("ok");
};
const useClose = () => {
visible.value = false;
};
return {
useBeforeCancel,
useBeforeChange,
useClose
};
}
export { useDrawerEvent };
//# sourceMappingURL=use-drawer-event.mjs.map