33 lines
718 B
Plaintext
33 lines
718 B
Plaintext
import { configCover } from "../libs/config.uts"
|
|
export { XTOAST_TYPE, XTOAST_TYPE_PRIVATE } from "../interface.uts"
|
|
let globalOpts:any | null = null;
|
|
export const hideToast = () => {
|
|
uni.hideToast()
|
|
globalOpts?.close();
|
|
}
|
|
|
|
export const showToast = (opts : any) => {
|
|
hideToast()
|
|
const config = configCover(opts)
|
|
globalOpts = config;
|
|
let title = config.title || config.content;
|
|
if(title){
|
|
wx.showToast({
|
|
title: config.title || config.content,
|
|
icon: config.iconCode || 'none',
|
|
duration: config.duration,
|
|
success(){
|
|
globalOpts?.close();
|
|
}
|
|
})
|
|
}else{
|
|
wx.showToast({
|
|
icon: config.iconCode || 'success',
|
|
duration: config.duration,
|
|
success(){
|
|
globalOpts?.close();
|
|
}
|
|
})
|
|
}
|
|
|
|
} |