new-ruoyi-geek/ruoyi-geek-app/plugins/modal.ts

100 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-11-15 13:07:57 +00:00
export default {
/**
*
* @param content
*/
msg(content: string): void {
uni.showToast({
title: content,
icon: 'none'
})
},
/**
*
* @param content
*/
msgError(content: string): void {
uni.showToast({
title: content,
icon: 'error'
})
},
/**
*
* @param content
*/
msgSuccess(content: string): void {
uni.showToast({
title: content,
icon: 'success'
})
},
/**
*
*/
hideMsg(): void {
uni.hideToast()
},
/**
*
* @param content
*/
alert(content: string): void {
uni.showModal({
title: '提示',
content: content,
showCancel: false
})
},
/**
*
* @param content
* @returns
*/
confirm(content: string): Promise<unknown> {
return new Promise((resolve: Function, reject: Function) => {
uni.showModal({
title: '系统提示',
content: content,
cancelText: '取消',
confirmText: '确定',
success: function (res) {
if (res.confirm) {
resolve(res.confirm)
}
}
})
})
},
/**
*
* @param option
*/
showToast(option: string | object): void {
if (typeof option === "object") {
uni.showToast(option)
} else {
uni.showToast({
title: option,
icon: "none",
duration: 2500
})
}
},
/**
*
* @param content
*/
loading(content: string): void {
uni.showLoading({
title: content
})
},
/**
*
*/
closeLoading(): void {
uni.hideLoading()
}
}