mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
50 lines
1.0 KiB
JavaScript
50 lines
1.0 KiB
JavaScript
import { ref } from 'vue'
|
|
|
|
const showConfirmModal = ref(false)
|
|
const confirmOptions = ref({
|
|
title: '',
|
|
message: '',
|
|
confirmText: '继续',
|
|
cancelText: '取消'
|
|
})
|
|
const confirmResolve = ref(null)
|
|
|
|
export function useConfirm() {
|
|
const showConfirm = (title, message, confirmText = '继续', cancelText = '取消') => {
|
|
return new Promise((resolve) => {
|
|
confirmOptions.value = {
|
|
title,
|
|
message,
|
|
confirmText,
|
|
cancelText
|
|
}
|
|
confirmResolve.value = resolve
|
|
showConfirmModal.value = true
|
|
})
|
|
}
|
|
|
|
const handleConfirm = () => {
|
|
showConfirmModal.value = false
|
|
if (confirmResolve.value) {
|
|
confirmResolve.value(true)
|
|
confirmResolve.value = null
|
|
}
|
|
}
|
|
|
|
const handleCancel = () => {
|
|
showConfirmModal.value = false
|
|
if (confirmResolve.value) {
|
|
confirmResolve.value(false)
|
|
confirmResolve.value = null
|
|
}
|
|
}
|
|
|
|
return {
|
|
showConfirmModal,
|
|
confirmOptions,
|
|
showConfirm,
|
|
handleConfirm,
|
|
handleCancel
|
|
}
|
|
}
|