ytptube/ui/composables/useConfirm.ts
2025-06-03 20:05:13 +03:00

23 lines
567 B
TypeScript

import { useStorage } from '@vueuse/core'
const reduceConfirm = useStorage<boolean>('reduce_confirm', false)
function confirm(msg: string, force: boolean = false): boolean {
if (false === force && true === reduceConfirm.value) {
return true
}
return window.confirm(msg)
}
function alert(msg: string): boolean {
return window.confirm(msg)
}
function prompt(msg: string, defaultValue: string = ''): string | null {
return window.prompt(msg, defaultValue)
}
export default function useConfirm() {
return { confirm, alert, prompt, reduceConfirm }
}