46 行
952 B
JavaScript
46 行
952 B
JavaScript
import Swal from 'sweetalert2';
|
|
|
|
const SelfSwal = Swal.mixin({
|
|
customClass: {
|
|
confirmButton: 'btn-round-full-single',
|
|
cancelButton: 'btn-round-full-single',
|
|
},
|
|
buttonsStyling: false,
|
|
heightAuto: false
|
|
});
|
|
|
|
// ajax
|
|
export const success = content => {
|
|
return SelfSwal.fire({
|
|
html: content,
|
|
showConfirmButton: false,
|
|
timer: 1000,
|
|
icon: 'success'
|
|
});
|
|
}
|
|
export const failed = (content, afterRetry) => {
|
|
return afterRetry ?
|
|
SelfSwal.fire({
|
|
html: content,
|
|
showCancelButton: true,
|
|
confirmButtonText: '重试',
|
|
cancelButtonText: '放弃'
|
|
})
|
|
.then(result => result.isConfirmed ? afterRetry() : null) :
|
|
SelfSwal.fire({
|
|
html: content,
|
|
showConfirmButton: false,
|
|
timer: 1000,
|
|
icon: 'error'
|
|
})
|
|
.then(() => null);
|
|
}
|
|
|
|
export const alert = (content) => {
|
|
return SelfSwal.fire({
|
|
html: content,
|
|
confirmButtonText: '了解',
|
|
icon: 'warning'
|
|
});
|
|
}
|