34 lines
851 B
TypeScript
34 lines
851 B
TypeScript
![]() |
import { defineNuxtPlugin } from '#app';
|
||
|
import Swal from 'sweetalert2';
|
||
|
import 'sweetalert2/dist/sweetalert2.min.css';
|
||
|
|
||
|
export default defineNuxtPlugin(nuxtApp => {
|
||
|
const mySwalToast = (options:any) => {
|
||
|
return Swal.fire({
|
||
|
toast: true,
|
||
|
position: 'bottom-end',
|
||
|
showConfirmButton: false,
|
||
|
timerProgressBar: true,
|
||
|
timer: 5000,
|
||
|
icon: 'success',
|
||
|
...options,
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const mySwalConfirm = (options:any) => {
|
||
|
return Swal.fire({
|
||
|
title: 'هشدار',
|
||
|
text: 'آیا مطمئن هستید؟',
|
||
|
icon: 'warning',
|
||
|
showCancelButton: true,
|
||
|
confirmButtonText: 'تایید',
|
||
|
cancelButtonText: 'انصراف',
|
||
|
...options,
|
||
|
});
|
||
|
};
|
||
|
|
||
|
// به جای استفاده از `provide()`
|
||
|
nuxtApp.$mySwalToast = mySwalToast;
|
||
|
nuxtApp.$mySwalConfirm = mySwalConfirm;
|
||
|
});
|