Files
claude-relay-service/web/admin-spa/src/composables/useConfirm.js
shaw 9c4dc714f8 Revert "Merge pull request #424 from Wangnov/feat/i18n"
This reverts commit 1d915d8327, reversing
changes made to 009f7c84f6.
2025-09-12 09:21:53 +08:00

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
}
}