mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-29 22:17:50 +08:00
fix:删帖需要给发帖者提示
This commit is contained in:
42
frontend_nuxt/composables/useConfirm.js
Normal file
42
frontend_nuxt/composables/useConfirm.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
const state = ref({
|
||||
visible: false,
|
||||
title: '',
|
||||
message: '',
|
||||
resolve: null,
|
||||
reject: null,
|
||||
})
|
||||
|
||||
export const useConfirm = () => {
|
||||
const confirm = (title, message) => {
|
||||
state.value.title = title
|
||||
state.value.message = message
|
||||
state.value.visible = true
|
||||
return new Promise((resolve, reject) => {
|
||||
state.value.resolve = resolve
|
||||
state.value.reject = reject
|
||||
})
|
||||
}
|
||||
|
||||
const onConfirm = () => {
|
||||
if (state.value.resolve) {
|
||||
state.value.resolve(true)
|
||||
}
|
||||
state.value.visible = false
|
||||
}
|
||||
|
||||
const onCancel = () => {
|
||||
if (state.value.reject) {
|
||||
state.value.reject(false)
|
||||
}
|
||||
state.value.visible = false
|
||||
}
|
||||
|
||||
return {
|
||||
confirm,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
state,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user