31 lines
755 B
TypeScript
31 lines
755 B
TypeScript
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
let loadingInstance: ReturnType<typeof ElLoading.service> | null = null
|
|
|
|
export const $modal = {
|
|
msgSuccess(msg: string) {
|
|
ElMessage.success(msg)
|
|
},
|
|
msgError(msg: string) {
|
|
ElMessage.error(msg)
|
|
},
|
|
msgWarning(msg: string) {
|
|
ElMessage.warning(msg)
|
|
},
|
|
confirm(msg: string, title = '提示') {
|
|
return ElMessageBox.confirm(msg, title, {
|
|
type: 'warning',
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消'
|
|
})
|
|
},
|
|
loading(text: string) {
|
|
loadingInstance?.close()
|
|
loadingInstance = ElLoading.service({ text, background: 'rgba(0,0,0,0.05)' })
|
|
},
|
|
closeLoading() {
|
|
loadingInstance?.close()
|
|
loadingInstance = null
|
|
}
|
|
}
|