Files
frontend_hmi/src/utils/useDialog.ts

33 lines
597 B
TypeScript
Raw Normal View History

2025-09-22 17:44:31 +08:00
import { ref } from 'vue';
/**
* Dialog控制Hook
* @returns visibleshowhidetoggle
*/
export function useDialog(initialVisible:boolean = false): {
visible: import('vue').Ref<boolean>,
show: () => void,
hide: () => void,
toggle: () => void
} {
const visible = ref(initialVisible);
const show = () => {
visible.value = true;
};
const hide = () => {
visible.value = false;
};
const toggle = () => {
visible.value = !visible.value;
};
return {
visible,
show,
hide,
toggle
};
}