Files
frontend_hmi/src/utils/useDialog.ts
2025-09-22 17:44:31 +08:00

33 lines
597 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ref } from 'vue';
/**
* Dialog控制Hook
* @returns visible显隐状态、show显示、hide隐藏、toggle切换
*/
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
};
}