|
|
@@ -1,11 +1,5 @@
|
|
|
import Swal from "sweetalert2"
|
|
|
|
|
|
-export const Toast = Swal.mixin({
|
|
|
- toast: true,
|
|
|
- position: "top-end",
|
|
|
- showConfirmButton: false,
|
|
|
-})
|
|
|
-
|
|
|
const DEFAULT_MESSAGE_BOX_CONFIG = {
|
|
|
defalut: {
|
|
|
buttonsStyling: false,
|
|
|
@@ -105,19 +99,35 @@ export const showToast = (type: string, message: string | undefined, callback?:
|
|
|
const messageContent = {} as any
|
|
|
messageContent.type = type
|
|
|
|
|
|
+ let opt: any = {
|
|
|
+ toast: true,
|
|
|
+ position: "top-end",
|
|
|
+ width: "360px",
|
|
|
+ showConfirmButton: false,
|
|
|
+ }
|
|
|
+ if (type == "success") {
|
|
|
+ opt.timer = 2000
|
|
|
+ opt.timerProgressBar = true
|
|
|
+ opt.didOpen = (toast: any) => {
|
|
|
+ toast.addEventListener("mouseenter", Swal.stopTimer)
|
|
|
+ toast.addEventListener("mouseleave", Swal.resumeTimer)
|
|
|
+ }
|
|
|
+ message = message || "操作成功"
|
|
|
+ }
|
|
|
if (message) {
|
|
|
messageContent.title = message
|
|
|
}
|
|
|
-
|
|
|
- const opt = Object.assign(
|
|
|
- {},
|
|
|
+ opt = Object.assign(
|
|
|
+ opt,
|
|
|
//DEFAULT_MESSAGE_BOX_CONFIG.defalut,
|
|
|
DEFAULT_MESSAGE_BOX_CONFIG[type],
|
|
|
messageContent,
|
|
|
options || {}
|
|
|
)
|
|
|
+ //console.log("TOAST", opt)
|
|
|
+
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- Toast.fire(opt)
|
|
|
+ Swal.fire(opt)
|
|
|
.then((isConfirmed) => {
|
|
|
callback && callback(isConfirmed)
|
|
|
resolve(isConfirmed)
|