useDialog.ts 502 B

12345678910111213141516171819202122232425262728293031
  1. import { Ref } from 'vue';
  2. interface Options {
  3. title?: string;
  4. }
  5. interface Return {
  6. title: Ref<string>;
  7. visible: Ref<boolean>;
  8. openDialog: () => void;
  9. closeDialog: () => void;
  10. }
  11. export default (ops?: Options): Return => {
  12. const visible = ref(false);
  13. const title = ref(ops.title || '');
  14. const openDialog = () => {
  15. visible.value = true;
  16. };
  17. const closeDialog = () => {
  18. visible.value = false;
  19. };
  20. return {
  21. title,
  22. visible,
  23. openDialog,
  24. closeDialog
  25. };
  26. };