UnisKB/ui/src/utils/message.ts

62 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-05-20 09:50:14 +00:00
import { ElMessageBox, ElMessage } from 'element-plus'
2025-01-13 03:15:51 +00:00
import { t } from '@/locales'
2023-10-13 08:11:54 +00:00
export const MsgSuccess = (message: string) => {
ElMessage.success({
message: message,
type: 'success',
showClose: true,
duration: 3000
2023-10-13 08:11:54 +00:00
})
}
export const MsgInfo = (message: string) => {
ElMessage.info({
message: message,
type: 'info',
showClose: true,
duration: 3000
2023-10-13 08:11:54 +00:00
})
}
export const MsgWarning = (message: string) => {
ElMessage.warning({
message: message,
type: 'warning',
showClose: true,
duration: 3000
2023-10-13 08:11:54 +00:00
})
}
export const MsgError = (message: string) => {
ElMessage.error({
message: message,
type: 'error',
showClose: true,
duration: 3000
2023-10-13 08:11:54 +00:00
})
}
export const MsgAlert = (title: string, description: string, options?: any) => {
const defaultOptions: Object = {
2025-01-13 03:15:51 +00:00
confirmButtonText: t('common.confirm'),
...options
}
return ElMessageBox.alert(description, title, defaultOptions)
}
2023-10-26 10:37:13 +00:00
/**
2023-12-18 03:32:29 +00:00
*
2024-04-15 07:26:46 +00:00
* @param message: {title, description,type}
2023-10-26 10:37:13 +00:00
*/
2024-04-15 07:26:46 +00:00
export const MsgConfirm = (title: string, description: string, options?: any) => {
2023-10-13 08:11:54 +00:00
const defaultOptions: Object = {
2023-10-26 10:37:13 +00:00
showCancelButton: true,
2025-01-13 03:15:51 +00:00
confirmButtonText: t('common.confirm'),
cancelButtonText: t('common.cancel'),
2023-10-13 08:11:54 +00:00
...options
}
2024-04-15 07:26:46 +00:00
return ElMessageBox.confirm(description, title, defaultOptions)
2023-10-13 08:11:54 +00:00
}